context.xml.svn-base 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <beans xmlns="http://www.springframework.org/schema/beans"
  2. xmlns:context="http://www.springframework.org/schema/context"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
  4. xmlns:cache="http://www.springframework.org/schema/cache"
  5. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
  6. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
  7. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
  8. http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd">
  9. <context:property-placeholder location="classpath*:*.properties" />
  10. <context:component-scan base-package="com.uas.saas" />
  11. <context:annotation-config />
  12. <!-- 国际化的消息资源文件(本系统中主要用于显示/错误消息定制) -->
  13. <bean id="messageSource"
  14. class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
  15. <property name="basenames">
  16. <list>
  17. <value>classpath:spring/messages</value>
  18. </list>
  19. </property>
  20. <property name="useCodeAsDefaultMessage" value="false" />
  21. <property name="defaultEncoding" value="UTF-8" />
  22. <property name="cacheSeconds" value="60" />
  23. </bean>
  24. <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
  25. destroy-method="close">
  26. <property name="driverClassName" value="${jdbc.driverClassName}" />
  27. <property name="url" value="${jdbc.url}" />
  28. <property name="username" value="${jdbc.username}" />
  29. <property name="password" value="${jdbc.password}" />
  30. <!-- 连接初始值,连接池启动时创建的连接数量的初始值 -->
  31. <property name="initialSize" value="${jdbc.initialSize}" />
  32. <!-- 连接池的最大值,同一时间可以从池分配的最多连接数量,0时无限制 -->
  33. <property name="maxActive" value="${jdbc.maxActive}" />
  34. <!-- 最大空闲值.当经过一个高峰时间后,连接池可以慢慢将已经用不到的连接慢慢释放一部分,一直减少到maxIdle为止 ,0时无限制 -->
  35. <property name="maxIdle" value="${jdbc.maxIdle}" />
  36. <!-- 最小空闲值.当空闲的连接数少于阀值时,连接池就会预申请去一些连接,以免洪峰来时来不及申请 -->
  37. <property name="minIdle" value="${jdbc.minIdle}" />
  38. <!-- 是否对已备语句进行池管理(布尔值),是否对PreparedStatement进行缓存 -->
  39. <property name="poolPreparedStatements" value="true" />
  40. <!-- 是否对sql进行自动提交 -->
  41. <property name="defaultAutoCommit" value="true" />
  42. <!-- 回收超时连接 -->
  43. <property name="removeAbandoned" value="true" />
  44. <!-- 连接空闲时校验连接有效性 -->
  45. <property name="testWhileIdle" value="true" />
  46. <!-- 校验连接有效性的sql -->
  47. <property name="validationQuery" value="select 1 from dual" />
  48. <!-- 每过timeBetweenEvictionRunsMillis 时间,就会启动一个线程,校验连接池中闲置时间超过minEvictableIdleTimeMillis的连接对象 -->
  49. <property name="timeBetweenEvictionRunsMillis" value="${jdbc.timeBetweenEvictionRunsMillis}" />
  50. <property name="minEvictableIdleTimeMillis" value="${jdbc.minEvictableIdleTimeMillis}" />
  51. </bean>
  52. <!-- hibernate jpa -->
  53. <bean class="org.springframework.orm.jpa.JpaTransactionManager"
  54. id="transactionManager">
  55. <property name="entityManagerFactory" ref="entityManagerFactory" />
  56. </bean>
  57. <tx:annotation-driven mode="aspectj" transaction-manager="transactionManager" />
  58. <bean id="transactionInterceptor"
  59. class="org.springframework.transaction.interceptor.TransactionInterceptor">
  60. <property name="transactionManager" ref="transactionManager" />
  61. <property name="transactionAttributeSource">
  62. <bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"></bean>
  63. </property>
  64. </bean>
  65. <bean id="transactionAttributeSourceAdvisor"
  66. class="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor">
  67. <property name="transactionInterceptor" ref="transactionInterceptor" />
  68. </bean>
  69. <bean id="entityManagerFactory"
  70. class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
  71. <property name="persistenceUnitName" value="persistenceUnit" />
  72. <property name="dataSource" ref="dataSource" />
  73. <property name="jpaVendorAdapter">
  74. <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
  75. <property name="generateDdl" value="false" />
  76. <property name="databasePlatform" value="org.hibernate.dialect.Oracle10gDialect" />
  77. <property name="showSql" value="true" />
  78. </bean>
  79. </property>
  80. <property name="jpaDialect">
  81. <bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
  82. </property>
  83. <property name="jpaProperties">
  84. <props>
  85. <prop key="hibernate.cache.provider_configuration_file_resource_path">classpath:spring/ehcache.xml</prop>
  86. <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
  87. </prop>
  88. <prop key="hibernate.cache.use_query_cache">true</prop>
  89. <prop key="hibernate.cache.use_second_level_cache">true</prop>
  90. <prop key="hibernate.generate_statistics">true</prop>
  91. <prop key="hibernate.use_sql_comments">true</prop>
  92. <prop key="hibernate.format_sql">true</prop>
  93. <prop key="hibernate.generate_statistics">true</prop>
  94. </props>
  95. </property>
  96. </bean>
  97. <!-- jdbctemplate -->
  98. <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
  99. <property name="dataSource" ref="dataSource" />
  100. </bean>
  101. <!-- 使用ehcache对象缓存 -->
  102. <cache:annotation-driven />
  103. <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
  104. <property name="cacheManager" ref="ehcache"></property>
  105. </bean>
  106. <bean id="ehcache"
  107. class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
  108. <property name="configLocation" value="classpath:spring/ehcache.xml"></property>
  109. <property name="shared" value="true"></property>
  110. </bean>
  111. <!-- mail sender -->
  112. <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
  113. <property name="host" value="${email.host}" />
  114. <property name="port" value="${email.port}" />
  115. <property name="javaMailProperties">
  116. <props>
  117. <prop key="mail.smtp.auth">true</prop>
  118. <prop key="mail.smtp.timeout">25000</prop>
  119. <prop key="mail.smtp.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
  120. <prop key="mail.smtp.port">465</prop>
  121. <prop key="mail.smtp.socketFactory.port">465</prop>
  122. </props>
  123. </property>
  124. <property name="username" value="${email.username}" />
  125. <property name="password" value="${email.password}" />
  126. </bean>
  127. <bean id="simpleMailMessage" class="org.springframework.mail.SimpleMailMessage">
  128. <property name="from" value="${email.from}" />
  129. </bean>
  130. <!-- 文件上传 -->
  131. <bean id="multipartResolver"
  132. class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
  133. <property name="defaultEncoding" value="utf-8"></property>
  134. </bean>
  135. </beans>