context.xml 8.3 KB

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