`
EricDanniel
  • 浏览: 16138 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

集成struts2 spring hibernate,使用注解

阅读更多

集成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>
  1. <filter>  
  2.     <filter-name>struts2</filter-name>  
  3.     <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>  
  4. </filter>  
  5.   
  6. <filter-mapping>  
  7.     <filter-name>struts2</filter-name>  
  8.     <url-pattern>*.action</url-pattern>  
  9. </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>
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"  
  3.         "http://struts.apache.org/dtds/struts-2.1.dtd">  
  4. <struts>  
  5.     <constant name="struts.devMode" value="true" />  
  6.     <constant name="struts.convention.default.parent.package" value="default-package" />  
  7.     <constant name="struts.convention.package.locators" value="action" />  
  8.     <package name="default-package" extends="convention-default">  
  9.   
  10.         <default-action-ref name="index" />  
  11.   
  12.         <action name="index"  >  
  13.             <result>/WEB-INF/content/index.jsp</result>  
  14.         </action>      
  15.   
  16.     </package>  
  17. </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>
  1. <listener>  
  2.     <listener-class>org.springframework.web.context.ContextLoaderListener  
  3.     </listener-class>  
  4. </listener>  
  5. <context-param>  
  6.     <param-name>contextConfigLocation</param-name>  
  7.     <param-value>classpath:/applicationContext.xml</param-value>  
  8. </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>
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans>  
  3.   
  4.     <context:component-scan base-package="persistence,service,action,aop"/>  
  5.       
  6.     <aop:aspectj-autoproxy  />  
  7.   
  8.     <tx:annotation-driven transaction-manager="transactionManager" />  
  9.       
  10.     <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" >  
  11.         <property name="sessionFactory" ref="sessionFactory" />  
  12.     </bean>  
  13.   
  14.     <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" >     
  15.         <property name="configLocation" value="classpath:hibernate.cfg.xml" />  
  16.     </bean>  
  17.   
  18.     <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate" >  
  19.         <property name="sessionFactory" ref="sessionFactory" />  
  20.     </bean>  
  21.       
  22. </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>
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">  
  3. <hibernate-configuration>  
  4.     <session-factory>  
  5.         <property name="hibernate.dialect"font-weight: bold; color:
    分享到:
    评论

相关推荐

Global site tag (gtag.js) - Google Analytics