applicationContext.xml 4.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans default-lazy-init="false"
  3. xmlns="http://www.springframework.org/schema/beans"
  4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5. xmlns:context="http://www.springframework.org/schema/context"
  6. xmlns:tx="http://www.springframework.org/schema/tx"
  7. xmlns:util="http://www.springframework.org/schema/util"
  8. xmlns:mvc="http://www.springframework.org/schema/mvc"
  9. xsi:schemaLocation="http://www.springframework.org/schema/beans
  10. http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
  11. http://www.springframework.org/schema/tx
  12. http://www.springframework.org/schema/tx/spring-tx.xsd
  13. http://www.springframework.org/schema/context
  14. http://www.springframework.org/schema/context/spring-context.xsd
  15. http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
  16. http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"
  17. xmlns:aop="http://www.springframework.org/schema/aop">
  18. <!--业务Beans, 使用注解方式配置-->
  19. <context:component-scan base-package="com.yihu.hos">
  20. </context:component-scan>
  21. <!--Hibernate 数据库配置-->
  22. <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
  23. <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
  24. <property name="url" value="jdbc:mysql://172.19.103.71:3306/esb?useUnicode=true&amp;characterEncoding=UTF-8"/>
  25. <property name="username" value="hos"/>
  26. <property name="password" value="hos"/>
  27. <property name="initialSize" value="1"/>
  28. <property name="maxTotal" value="100"/>
  29. <property name="maxIdle" value="50"/>
  30. <property name="minIdle" value="20"/>
  31. <property name="validationQuery" value="SELECT 1"/>
  32. <property name="testOnBorrow" value="true"/>
  33. <property name="removeAbandonedTimeout" value="55"/>
  34. </bean>
  35. <!--Hibernate 会话管理器配置-->
  36. <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
  37. <property name="dataSource" ref="dataSource"/>
  38. <property name="packagesToScan">
  39. <list>
  40. <!-- 可以加多个包 -->
  41. <value>com.yihu.hos.rest.models</value>
  42. </list>
  43. </property>
  44. <property name="hibernateProperties">
  45. <value>
  46. hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
  47. hibernate.show_sql=false
  48. hibernate.format_sql=true
  49. </value>
  50. </property>
  51. <property name="mappingLocations">
  52. <list>
  53. <!-- <value>classpath:hbm/*.hbm.xml</value>-->
  54. <value>classpath:hibernate/*.hbm.xml</value>
  55. </list>
  56. </property>
  57. </bean>
  58. <!-- 将多个配置文件读取到容器中,交给Spring管理 -->
  59. <!--Hibernate 事务配置-->
  60. <bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
  61. <property name="sessionFactory" ref="sessionFactory"/>
  62. </bean>
  63. <tx:annotation-driven transaction-manager="txManager" proxy-target-class="true"/>
  64. <!--文件上传支持-->
  65. <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>
  66. <bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
  67. <property name="cookieMaxAge" value="604800"/>
  68. <property name="defaultLocale" value="zh_CN"/>
  69. <property name="cookieName" value="Language"></property>
  70. </bean>
  71. <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"/>
  72. <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
  73. <property name="dataSource" ref="dataSource"/>
  74. </bean>
  75. <!--Hibernate模版配置 -->
  76. <bean id="hibernateTemplate" class="org.springframework.orm.hibernate4.HibernateTemplate">
  77. <property name="sessionFactory" ref="sessionFactory"></property>
  78. </bean>
  79. <!--<bean id="quartzScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" scope="singleton">-->
  80. <!--<property name="dataSource" ref="dataSource"/>-->
  81. <!--<property name="configLocation" value="classpath:/config/quartz.properties" />-->
  82. <!--<property name="autoStartup" value="true"/>-->
  83. <!--</bean>-->
  84. </beans>