集成struts,spring,hibernate时,对于初学者来说最大的麻烦就其繁琐的xml配置文件。现在三者都对基于注解的配置提供了良好的支持。在struts2中,使用convent plugin,得益于annotation和规约,配置过程得以大大减少。在spring2.5也可以使用@Autowired,进行注入,使用@Controller,@Service,@Repository注解,自动定义bean,还支持annotation风格的声明式事务支持,以及aspectJ类似的AOP。hibernate也可以使用JPA标准注解定义实体描述,避免使用mapping文件。
当然,对于annotation和xml风格的配置,谁更好,更多依赖个人兴趣。但使用annotation确实减少了很多配置工作量。本文采用annotation风格的配置,以TaskList为例子讲解struts2 spring hibernate的集成。项目文件见附件。
一:配置struts2。
首先在web.xml文件中配置filter
Xml代码
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="14" height="15" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
<param name="flashvars" value="clipboard=%09%3Cfilter%3E%0A%09%09%3Cfilter-name%3Estruts2%3C%2Ffilter-name%3E%0A%09%09%3Cfilter-class%3Eorg.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter%3C%2Ffilter-class%3E%0A%09%3C%2Ffilter%3E%0A%0A%09%3Cfilter-mapping%3E%0A%09%09%3Cfilter-name%3Estruts2%3C%2Ffilter-name%3E%0A%09%09%3Curl-pattern%3E*.action%3C%2Furl-pattern%3E%0A%09%3C%2Ffilter-mapping%3E">
<param name="src" value="http://www.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf">
<embed type="application/x-shockwave-flash" width="14" height="15" src="http://www.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=%09%3Cfilter%3E%0A%09%09%3Cfilter-name%3Estruts2%3C%2Ffilter-name%3E%0A%09%09%3Cfilter-class%3Eorg.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter%3C%2Ffilter-class%3E%0A%09%3C%2Ffilter%3E%0A%0A%09%3Cfilter-mapping%3E%0A%09%09%3Cfilter-name%3Estruts2%3C%2Ffilter-name%3E%0A%09%09%3Curl-pattern%3E*.action%3C%2Furl-pattern%3E%0A%09%3C%2Ffilter-mapping%3E"></embed></object>
- <filter>
- <filter-name>struts2</filter-name>
- <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
- </filter>
-
- <filter-mapping>
- <filter-name>struts2</filter-name>
- <url-pattern>*.action</url-pattern>
- </filter-mapping>
然后在classpath中创建struts.xml配置文件。
Xml代码
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="14" height="15" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
<param name="flashvars" value="clipboard=%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%0A%3C!DOCTYPE%20struts%20PUBLIC%20%22-%2F%2FApache%20Software%20Foundation%2F%2FDTD%20Struts%20Configuration%202.1%2F%2FEN%22%0A%20%20%20%20%20%20%20%20%22http%3A%2F%2Fstruts.apache.org%2Fdtds%2Fstruts-2.1.dtd%22%3E%0A%3Cstruts%3E%0A%09%3Cconstant%20name%3D%22struts.devMode%22%20value%3D%22true%22%20%2F%3E%0A%09%3Cconstant%20name%3D%22struts.convention.default.parent.package%22%20value%3D%22default-package%22%20%2F%3E%0A%09%3Cconstant%20name%3D%22struts.convention.package.locators%22%20value%3D%22action%22%20%2F%3E%0A%09%3Cpackage%20name%3D%22default-package%22%20extends%3D%22convention-default%22%3E%0A%0A%09%09%3Cdefault-action-ref%20name%3D%22index%22%20%2F%3E%0A%0A%09%09%3Caction%20name%3D%22index%22%20%20%3E%0A%09%09%09%3Cresult%3E%2FWEB-INF%2Fcontent%2Findex.jsp%3C%2Fresult%3E%0A%09%09%3C%2Faction%3E%09%0A%0A%09%3C%2Fpackage%3E%0A%3C%2Fstruts%3E">
<param name="src" value="http://www.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf">
<embed type="application/x-shockwave-flash" width="14" height="15" src="http://www.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%0A%3C!DOCTYPE%20struts%20PUBLIC%20%22-%2F%2FApache%20Software%20Foundation%2F%2FDTD%20Struts%20Configuration%202.1%2F%2FEN%22%0A%20%20%20%20%20%20%20%20%22http%3A%2F%2Fstruts.apache.org%2Fdtds%2Fstruts-2.1.dtd%22%3E%0A%3Cstruts%3E%0A%09%3Cconstant%20name%3D%22struts.devMode%22%20value%3D%22true%22%20%2F%3E%0A%09%3Cconstant%20name%3D%22struts.convention.default.parent.package%22%20value%3D%22default-package%22%20%2F%3E%0A%09%3Cconstant%20name%3D%22struts.convention.package.locators%22%20value%3D%22action%22%20%2F%3E%0A%09%3Cpackage%20name%3D%22default-package%22%20extends%3D%22convention-default%22%3E%0A%0A%09%09%3Cdefault-action-ref%20name%3D%22index%22%20%2F%3E%0A%0A%09%09%3Caction%20name%3D%22index%22%20%20%3E%0A%09%09%09%3Cresult%3E%2FWEB-INF%2Fcontent%2Findex.jsp%3C%2Fresult%3E%0A%09%09%3C%2Faction%3E%09%0A%0A%09%3C%2Fpackage%3E%0A%3C%2Fstruts%3E"></embed></object>
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
- "http://struts.apache.org/dtds/struts-2.1.dtd">
- <struts>
- <constant name="struts.devMode" value="true" />
- <constant name="struts.convention.default.parent.package" value="default-package" />
- <constant name="struts.convention.package.locators" value="action" />
- <package name="default-package" extends="convention-default">
-
- <default-action-ref name="index" />
-
- <action name="index" >
- <result>/WEB-INF/content/index.jsp</result>
- </action>
-
- </package>
- </struts>
struts.devMode属性,配置启用调试,将有更多的错误信息输出,便于排错。struts.convention.default.parent.package属性,指定使用注解标注的控制器的默认包。可以在这个默认包中配置全局信息。
struts.convention.package.locators属性,为查找控制器包路径的关键字。如com.mycompany.action,com.mycompany.action.user,都会被struts2扫描。里面有继承至Action的类,或类名以Action结尾的类,都会做为Action处理。
<default-action-ref name="index" />指定了默认action,如果指定的action不存在则访问该action。
把struts2-spring-plugin-2.1.6.jar添加到classpath中,struts2会自动扫描struts-plugin.xml文件,该文件自动注册了com.opensymphony.xwork2.ObjectFactory,完成和spring的集成。
二:配置spring
在web.xml中加入ContextLoaderListener,用以启动spring容器。用contextConfigLocation指定spring配置文件路径,可以使用*通配符结尾。
Xml代码
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="14" height="15" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
<param name="flashvars" value="clipboard=%09%3Clistener%3E%0A%09%09%3Clistener-class%3Eorg.springframework.web.context.ContextLoaderListener%0A%09%09%3C%2Flistener-class%3E%0A%09%3C%2Flistener%3E%0A%09%3Ccontext-param%3E%0A%09%09%3Cparam-name%3EcontextConfigLocation%3C%2Fparam-name%3E%0A%09%09%3Cparam-value%3Eclasspath%3A%2FapplicationContext.xml%3C%2Fparam-value%3E%0A%09%3C%2Fcontext-param%3E">
<param name="src" value="http://www.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf">
<embed type="application/x-shockwave-flash" width="14" height="15" src="http://www.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=%09%3Clistener%3E%0A%09%09%3Clistener-class%3Eorg.springframework.web.context.ContextLoaderListener%0A%09%09%3C%2Flistener-class%3E%0A%09%3C%2Flistener%3E%0A%09%3Ccontext-param%3E%0A%09%09%3Cparam-name%3EcontextConfigLocation%3C%2Fparam-name%3E%0A%09%09%3Cparam-value%3Eclasspath%3A%2FapplicationContext.xml%3C%2Fparam-value%3E%0A%09%3C%2Fcontext-param%3E"></embed></object>
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener
- </listener-class>
- </listener>
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>classpath:/applicationContext.xml</param-value>
- </context-param>
配置applicationContext.xml
Xml代码
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="14" height="15" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
<param name="flashvars" value="clipboard=%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%0A%3Cbeans%3E%0A%0A%09%3Ccontext%3Acomponent-scan%20base-package%3D%22persistence%2Cservice%2Caction%2Caop%22%2F%3E%0A%09%0A%09%3Caop%3Aaspectj-autoproxy%20%20%2F%3E%0A%0A%09%3Ctx%3Aannotation-driven%20transaction-manager%3D%22transactionManager%22%20%2F%3E%0A%09%0A%09%3Cbean%20id%3D%22transactionManager%22%20class%3D%22org.springframework.orm.hibernate3.HibernateTransactionManager%22%20%3E%0A%09%09%3Cproperty%20name%3D%22sessionFactory%22%20ref%3D%22sessionFactory%22%20%2F%3E%0A%09%3C%2Fbean%3E%0A%0A%09%3Cbean%20id%3D%22sessionFactory%22%20class%3D%22org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean%22%20%3E%09%0A%09%09%3Cproperty%20name%3D%22configLocation%22%20value%3D%22classpath%3Ahibernate.cfg.xml%22%20%2F%3E%0A%09%3C%2Fbean%3E%0A%0A%09%3Cbean%20id%3D%22hibernateTemplate%22%20class%3D%22org.springframework.orm.hibernate3.HibernateTemplate%22%20%3E%0A%09%09%3Cproperty%20name%3D%22sessionFactory%22%20ref%3D%22sessionFactory%22%20%2F%3E%0A%09%3C%2Fbean%3E%0A%09%0A%3C%2Fbeans%3E">
<param name="src" value="http://www.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf">
<embed type="application/x-shockwave-flash" width="14" height="15" src="http://www.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%0A%3Cbeans%3E%0A%0A%09%3Ccontext%3Acomponent-scan%20base-package%3D%22persistence%2Cservice%2Caction%2Caop%22%2F%3E%0A%09%0A%09%3Caop%3Aaspectj-autoproxy%20%20%2F%3E%0A%0A%09%3Ctx%3Aannotation-driven%20transaction-manager%3D%22transactionManager%22%20%2F%3E%0A%09%0A%09%3Cbean%20id%3D%22transactionManager%22%20class%3D%22org.springframework.orm.hibernate3.HibernateTransactionManager%22%20%3E%0A%09%09%3Cproperty%20name%3D%22sessionFactory%22%20ref%3D%22sessionFactory%22%20%2F%3E%0A%09%3C%2Fbean%3E%0A%0A%09%3Cbean%20id%3D%22sessionFactory%22%20class%3D%22org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean%22%20%3E%09%0A%09%09%3Cproperty%20name%3D%22configLocation%22%20value%3D%22classpath%3Ahibernate.cfg.xml%22%20%2F%3E%0A%09%3C%2Fbean%3E%0A%0A%09%3Cbean%20id%3D%22hibernateTemplate%22%20class%3D%22org.springframework.orm.hibernate3.HibernateTemplate%22%20%3E%0A%09%09%3Cproperty%20name%3D%22sessionFactory%22%20ref%3D%22sessionFactory%22%20%2F%3E%0A%09%3C%2Fbean%3E%0A%09%0A%3C%2Fbeans%3E"></embed></object>
- <?xml version="1.0" encoding="UTF-8"?>
- <beans>
-
- <context:component-scan base-package="persistence,service,action,aop"/>
-
- <aop:aspectj-autoproxy />
-
- <tx:annotation-driven transaction-manager="transactionManager" />
-
- <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" >
- <property name="sessionFactory" ref="sessionFactory" />
- </bean>
-
- <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" >
- <property name="configLocation" value="classpath:hibernate.cfg.xml" />
- </bean>
-
- <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate" >
- <property name="sessionFactory" ref="sessionFactory" />
- </bean>
-
- </beans>
<context:component-scan />指定Bean扫描的包,多个包逗号隔开,任何标注了@Component,@Controller,@Service,@Repository的类,都会被自动识别为bean。
<aop:aspectj-autoproxy />声明aspectj动态代理,启用注解驱动的aspectj配置。
<tx:annotation-driven />启用注解驱动的声明事务支持。
然后定义了sessionFactory和transactionManager,hibernateTemplate用来注入到Dao中,取代继承的方式使用spring对hibernate的集成支持。
三:hibernate配置
hibernate配置独立配置,方便修改。
Xml代码
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="14" height="15" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
<param name="flashvars" value="clipboard=%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%0A%3C!DOCTYPE%20hibernate-configuration%20PUBLIC%20%22-%2F%2FHibernate%2FHibernate%20Configuration%20DTD%203.0%2F%2FEN%22%20%22http%3A%2F%2Fhibernate.sourceforge.net%2Fhibernate-configuration-3.0.dtd%22%3E%0A%3Chibernate-configuration%3E%0A%09%3Csession-factory%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.dialect%22%3Eorg.hibernate.dialect.MySQLDialect%3C%2Fproperty%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.connection.driver_class%22%3Ecom.mysql.jdbc.Driver%3C%2Fproperty%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.connection.url%22%3Ejdbc%3Amysql%3A%2F%2Flocalhost%3A3306%2Fsshdemo%3C%2Fproperty%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.connection.username%22%3Eroot%3C%2Fproperty%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.connection.password%22%3Eroot%3C%2Fproperty%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.hbm2ddl.auto%22%3Eupdate%3C%2Fproperty%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.show_sql%22%3Etrue%3C%2Fproperty%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.format_sql%22%3Etrue%3C%2Fproperty%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.current_session_context_class%22%3Ethread%3C%2Fproperty%3E%09%09%0A%0A%09%09%3C!--%20%E6%9C%80%E5%A4%A7%E8%BF%9E%E6%8E%A5%E6%95%B0%20--%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.c3p0.max_size%22%3E20%3C%2Fproperty%3E%0A%20%20%20%20%20%20%20%20%3C!--%20%E6%9C%80%E5%B0%8F%E8%BF%9E%E6%8E%A5%E6%95%B0%20--%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.c3p0.min_size%22%3E5%3C%2Fproperty%3E%0A%20%20%20%20%20%20%20%20%3C!--%20%E8%8E%B7%E5%BE%97%E8%BF%9E%E6%8E%A5%E7%9A%84%E8%B6%85%E6%97%B6%E6%97%B6%E9%97%B4%2C%E5%A6%82%E6%9E%9C%E8%B6%85%E8%BF%87%E8%BF%99%E4%B8%AA%E6%97%B6%E9%97%B4%2C%E4%BC%9A%E6%8A%9B%E5%87%BA%E5%BC%82%E5%B8%B8%EF%BC%8C%E5%8D%95%E4%BD%8D%E6%AF%AB%E7%A7%92%20--%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.c3p0.timeout%22%3E120%3C%2Fproperty%3E%0A%20%20%20%20%20%20%20%20%3C!--%20%E6%9C%80%E5%A4%A7%E7%9A%84PreparedStatement%E7%9A%84%E6%95%B0%E9%87%8F%20--%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.c3p0.max_statements%22%3E100%3C%2Fproperty%3E%0A%20%20%20%20%20%20%20%20%3C!--%20%E6%AF%8F%E9%9A%94120%E7%A7%92%E6%A3%80%E6%9F%A5%E8%BF%9E%E6%8E%A5%E6%B1%A0%E9%87%8C%E7%9A%84%E7%A9%BA%E9%97%B2%E8%BF%9E%E6%8E%A5%20%EF%BC%8C%E5%8D%95%E4%BD%8D%E6%98%AF%E7%A7%92--%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.c3p0.idle_test_period%22%3E120%3C%2Fproperty%3E%0A%20%20%20%20%20%20%20%20%3C!--%20%E5%BD%93%E8%BF%9E%E6%8E%A5%E6%B1%A0%E9%87%8C%E9%9D%A2%E7%9A%84%E8%BF%9E%E6%8E%A5%E7%94%A8%E5%AE%8C%E7%9A%84%E6%97%B6%E5%80%99%EF%BC%8CC3P0%E4%B8%80%E4%B8%8B%E8%8E%B7%E5%8F%96%E7%9A%84%E6%96%B0%E7%9A%84%E8%BF%9E%E6%8E%A5%E6%95%B0%20--%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.c3p0.acquire_increment%22%3E2%3C%2Fproperty%3E%0A%20%20%20%20%20%20%20%20%3C!--%20%E6%AF%8F%E6%AC%A1%E9%83%BD%E9%AA%8C%E8%AF%81%E8%BF%9E%E6%8E%A5%E6%98%AF%E5%90%A6%E5%8F%AF%E7%94%A8%20--%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.c3p0.validate%22%3Etrue%3C%2Fproperty%3E%0A%0A%09%09%3Cmapping%20class%3D%22domain.Task%22%20%2F%3E%0A%09%3C%2Fsession-factory%3E%0A%3C%2Fhibernate-configuration%3E%0A">
<param name="src" value="http://www.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf">
<embed type="application/x-shockwave-flash" width="14" height="15" src="http://www.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%0A%3C!DOCTYPE%20hibernate-configuration%20PUBLIC%20%22-%2F%2FHibernate%2FHibernate%20Configuration%20DTD%203.0%2F%2FEN%22%20%22http%3A%2F%2Fhibernate.sourceforge.net%2Fhibernate-configuration-3.0.dtd%22%3E%0A%3Chibernate-configuration%3E%0A%09%3Csession-factory%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.dialect%22%3Eorg.hibernate.dialect.MySQLDialect%3C%2Fproperty%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.connection.driver_class%22%3Ecom.mysql.jdbc.Driver%3C%2Fproperty%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.connection.url%22%3Ejdbc%3Amysql%3A%2F%2Flocalhost%3A3306%2Fsshdemo%3C%2Fproperty%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.connection.username%22%3Eroot%3C%2Fproperty%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.connection.password%22%3Eroot%3C%2Fproperty%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.hbm2ddl.auto%22%3Eupdate%3C%2Fproperty%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.show_sql%22%3Etrue%3C%2Fproperty%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.format_sql%22%3Etrue%3C%2Fproperty%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.current_session_context_class%22%3Ethread%3C%2Fproperty%3E%09%09%0A%0A%09%09%3C!--%20%E6%9C%80%E5%A4%A7%E8%BF%9E%E6%8E%A5%E6%95%B0%20--%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.c3p0.max_size%22%3E20%3C%2Fproperty%3E%0A%20%20%20%20%20%20%20%20%3C!--%20%E6%9C%80%E5%B0%8F%E8%BF%9E%E6%8E%A5%E6%95%B0%20--%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.c3p0.min_size%22%3E5%3C%2Fproperty%3E%0A%20%20%20%20%20%20%20%20%3C!--%20%E8%8E%B7%E5%BE%97%E8%BF%9E%E6%8E%A5%E7%9A%84%E8%B6%85%E6%97%B6%E6%97%B6%E9%97%B4%2C%E5%A6%82%E6%9E%9C%E8%B6%85%E8%BF%87%E8%BF%99%E4%B8%AA%E6%97%B6%E9%97%B4%2C%E4%BC%9A%E6%8A%9B%E5%87%BA%E5%BC%82%E5%B8%B8%EF%BC%8C%E5%8D%95%E4%BD%8D%E6%AF%AB%E7%A7%92%20--%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.c3p0.timeout%22%3E120%3C%2Fproperty%3E%0A%20%20%20%20%20%20%20%20%3C!--%20%E6%9C%80%E5%A4%A7%E7%9A%84PreparedStatement%E7%9A%84%E6%95%B0%E9%87%8F%20--%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.c3p0.max_statements%22%3E100%3C%2Fproperty%3E%0A%20%20%20%20%20%20%20%20%3C!--%20%E6%AF%8F%E9%9A%94120%E7%A7%92%E6%A3%80%E6%9F%A5%E8%BF%9E%E6%8E%A5%E6%B1%A0%E9%87%8C%E7%9A%84%E7%A9%BA%E9%97%B2%E8%BF%9E%E6%8E%A5%20%EF%BC%8C%E5%8D%95%E4%BD%8D%E6%98%AF%E7%A7%92--%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.c3p0.idle_test_period%22%3E120%3C%2Fproperty%3E%0A%20%20%20%20%20%20%20%20%3C!--%20%E5%BD%93%E8%BF%9E%E6%8E%A5%E6%B1%A0%E9%87%8C%E9%9D%A2%E7%9A%84%E8%BF%9E%E6%8E%A5%E7%94%A8%E5%AE%8C%E7%9A%84%E6%97%B6%E5%80%99%EF%BC%8CC3P0%E4%B8%80%E4%B8%8B%E8%8E%B7%E5%8F%96%E7%9A%84%E6%96%B0%E7%9A%84%E8%BF%9E%E6%8E%A5%E6%95%B0%20--%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.c3p0.acquire_increment%22%3E2%3C%2Fproperty%3E%0A%20%20%20%20%20%20%20%20%3C!--%20%E6%AF%8F%E6%AC%A1%E9%83%BD%E9%AA%8C%E8%AF%81%E8%BF%9E%E6%8E%A5%E6%98%AF%E5%90%A6%E5%8F%AF%E7%94%A8%20--%3E%0A%09%09%3Cproperty%20name%3D%22hibernate.c3p0.validate%22%3Etrue%3C%2Fproperty%3E%0A%0A%09%09%3Cmapping%20class%3D%22domain.Task%22%20%2F%3E%0A%09%3C%2Fsession-factory%3E%0A%3C%2Fhibernate-configuration%3E%0A"></embed></object>
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
- <hibernate-configuration>
- <session-factory>
- <property name="hibernate.dialect"font-weight: bold; color:
分享到:
相关推荐
struts2.0 spring2.5 hibernate3.2 注解最新框架
Struts2 Spring3 Hibernate 注解功能 DAO 泛型 通用分页
Struts2+hibernate+spring开发,使用MySQL数据,实现学生基本信息的增删改查功能,但是页面不美观
SSH2 annotation 实现struts2.1.6 spring2.5.6 hibernate3.3 全注解开发 hibernate延迟加载_懒加载 具体应用
SSH三大框架整合 struts2+hibernate+spring (全注解方式进行配置)
Struts2 Spring3.0 Hibernate3.3 整合全注解配置用的数据库。
Struts2.3.28+spring4.1.6+hibernate4.3.8整合总结(注解),测试环境使用myeclipse2014,jdk1.6
Spring3Annotation+Struts2Annotation+Hibernate3Annotation 全注解集成开发,操作Emp表
struts2+HIbernate+Spring整合所需jar包 包含数据库连接池jar包 hibernate注解所需jar包 日志处理log4j及slf日志框架及实现的jar包
描述ssh框架的部分注解,包括hibernate实体类、spring data jpa 等重用注解的含义介绍,比较适用想学习基于注解的ssh框架的初学者。
struts2+spring+hibernate s2sh半注解结合方式框架搭建开发
b 在struts.xml中添加action,使用通配符的方式 , 注意这里和单独struts2不同的地方: class属性指向的是bean 的 id ,这里我们配置bean采用spring ioc注解的方式, 所以默认的bean的id 为 类名(首字母小写) ...
Struts2Spring4Hibernate4整合,Hibernate使用的是注解,没有使用Maven,这个是帮一个小伙伴整合做的demo
超级详细的SSH2项目实例详解,并且附带两个项目详解。两种注解实现方式。...在JavaEE企业级开发中,以SSH2框架为核心的应用非常广,大象根据项目实践经验,通过二个实例,详细的为大家讲解如何实现全注解式的开发。
(1)该项目是基于spring3+struts2+hibernate3+spring security3的权限管理项目 (2)后台我已经实现了权限管理,包括用户,角色和资源的分配。前台实现了spring security3的管理 (3)网上案例普遍是后台单一登陆。...
springmvc注解.doc,Spring注解讲解.doc,struts2标签详解.pdf,struts2常用标签.pdf,Struts2页面开发中常用标签.pdf,Struts2注解详细说明文档.doc,Hibernate注解教程:Hibernate Annotation使用实例.maff
NULL 博文链接:https://wangxuehui.iteye.com/blog/1636828
NULL 博文链接:https://tianlihu.iteye.com/blog/1815404
Struts2 Spring3.0 Hibernate3.3 全注解配置,避免了大量业务类在Spring文件的配置,整合了DWR3.0,displayTag 物理分页技术的实现。树形菜单。 另外数据库,在下一个资源;由于20MB的限制。 有问题的话留言。