最简单的SSH(Struts+Spring+Hibernate)[二]配置文件
2010-06-01 14:58
756 查看
orm.xml
persistence.xml
action.xml
b
l.xml
context.xml
dao.xml
struts.xml
web.xml
<?xml version="1.0" encoding="UTF-8"?> <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd" version="1.0"> </entity-mappings>
persistence.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- example of a default persistence.xml --> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0"> <persistence-unit name="PersistenceUnit"> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect" /> </properties> </persistence-unit> </persistence>
action.xml
<?xml version="1.0" encoding="UTF-8" ?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:lang="http://www.springframework.org/schema/lang" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.0.xsd" default-autowire="byName"> <bean id="userAction" scope="prototype" class="web.UserAction" /> </beans>
b
l.xml
<?xml version="1.0" encoding="UTF-8" ?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:lang="http://www.springframework.org/schema/lang" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.0.xsd" default-autowire="byName"> <bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor" /> <bean id="userService" class="business.impl.UserServiceImpl" /> </beans>
context.xml
<?xml version="1.0" encoding="UTF-8" ?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:lang="http://www.springframework.org/schema/lang" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.0.xsd"> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="ignoreResourceNotFound" value="true"/> <property name="locations"> <list> <value>classpath:jdbc.properties</value> </list> </property> </bean> <aop:spring-configured/> <import resource="dao.xml"/> <import resource="bl.xml"/> <import resource="action.xml"/> </beans>
dao.xml
<?xml version="1.0" encoding="UTF-8" ?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:lang="http://www.springframework.org/schema/lang" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.0.xsd"> <!-- bean post-processor for JPA annotations --> <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/> <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> <property name="database" value="${hibernate.database}" /> <property name="databasePlatform" value="${hibernate.dialect}" /> <property name="showSql" value="${hibernate.showSql}" /> <property name="generateDdl" value="${hibernate.generateDdl}" /> </bean> </property> <property name="jpaProperties"> <props> <prop key="hibernate.format_sql">false</prop> <prop key="hibernate.use_sql_comments">true</prop> <prop key="hibernate.generate_statistics">true</prop> <prop key="hibernate.connection.release_mode">after_transaction</prop> </props> </property> </bean> <tx:annotation-driven /> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" p:driverClass="${jdbc.driverClassName}" p:jdbcUrl="${jdbc.url}" p:initialPoolSize="${jdbc.initialPoolSize}" p:minPoolSize="${jdbc.minPoolSize}" p:acquireIncrement="${jdbc.acquireIncrement}" p:unreturnedConnectionTimeout="${jdbc.unreturnedConnectionTimeout}" p:maxPoolSize="${jdbc.maxPoolSize}" p:preferredTestQuery="select name from settings where id=1" p:idleConnectionTestPeriod="60" p:autoCommitOnClose="false" p:maxStatements="50" p:maxAdministrativeTaskTime="0" p:numHelperThreads="9" p:user="${jdbc.username}" p:password="${jdbc.password}" /> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory" /> <property name="dataSource" ref="dataSource" /> </bean> <bean id="userDao" class="dao.jpa.UserDAOJpaImpl"/> </beans>
struts.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <package name="leho" extends="struts-default"> <action name="list" method="execute" class="userAction"> <result>WEB-INF/pages/test.jsp</result> <result name="input">WEB-INF/pages/test.jsp</result> </action> <action name="add" method="add" class="userAction"> <result>WEB-INF/pages/test.jsp</result> <result name="input">WEB-INF/pages/test.jsp</result> </action> </package> </struts>
web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app id="ssh" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>SSH</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <!-- *************JPA Configuration************** --> <filter> <filter-name>jpaFilter</filter-name> <filter-class> org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter </filter-class> </filter> <filter-mapping> <filter-name>jpaFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- *********************** Spring configuration ***********************--> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:context.xml</param-value> </context-param> <!-- ************Struts Configuration************** --> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.FilterDispatcher </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
相关文章推荐
- 最简单的SSH(Struts+Spring+Hibernate)[三]配置文件和测试页面
- Hibernate hbm——SSH (Spring+Struts+Hibernate)框架搭建之配置文件序列五
- Struts2——SSH (Spring+Struts+Hibernate)框架搭建之配置文件序列一
- SSH整合Spring、Struts、Hibernate、web配置文件
- Spring——SSH (Spring+Struts+Hibernate)框架搭建之配置文件序列二
- Hibernate hbm 外键关联——SSH (Spring+Struts+Hibernate)框架搭建之配置文件序列六
- SSH:SSH(Struts1 + Spring + hibernate)整合之配置文件
- SSH(struts+spring+hibernate)迅速开发--第五章 定义配置和资源文件
- 最简单的SSH(Struts+Spring+Hibernate)[一]源文件
- SSH(struts 1.x+spring 2.5+hibernate 3.2)开发文件配置
- ssh整合!Struts.xml、hibernate与spring整合的applicationContext.xml、web.xml文件的配置!
- SSH:SSH(Struts1 + Spring + hibernate)整合之配置文件
- Spring beans——SSH (Spring+Struts+Hibernate)框架搭建之配置文件序列三
- Hibernate——SSH (Spring+Struts+Hibernate)框架搭建之配置文件序列四
- 整合Struts2.3.20 Spring4.1.3 Hibernate4.3.7 配置文件
- SSH学习笔记之关于struts-spring-hibernate整合配置问
- struts1.2 + spring2.5 + hibernate3.2框架搭建二之配置文件
- ssh整合之不带hibernate配置文件的spring中的配置
- 整合Struts2.3.20 Spring4.1.3 Hibernate4.3.7 配置文件
- Spring+Hibernate如何配置数据源(Struts Spring Hibernate (SSH) 整合实例)