applicationContext-test.xml 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xmlns:context="http://www.springframework.org/schema/context"
  5. xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
  6. xmlns:mvc="http://www.springframework.org/schema/mvc"
  7. xsi:schemaLocation="http://www.springframework.org/schema/beans
  8. http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
  9. http://www.springframework.org/schema/context
  10. http://www.springframework.org/schema/context/spring-context-4.2.xsd
  11. http://www.springframework.org/schema/tx
  12. http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
  13. http://www.springframework.org/schema/aop
  14. http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
  15. <context:component-scan base-package="com.kmall.framework.dao,com.kmall.framework.service">
  16. <!--过滤定时任务service-->
  17. <context:exclude-filter type="regex" expression="com.kmall.framework.service.impl.ScheduleJobServiceImpl"/>
  18. </context:component-scan>
  19. <bean id="placeholderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  20. <property name="locations">
  21. <list>
  22. <value>classpath:conf/db.properties</value>
  23. <value>classpath:conf/express-kdn.properties</value>
  24. <value>classpath:conf/redis.properties</value>
  25. <value>classpath:conf/cus.properties</value>
  26. <value>classpath:conf/servlet.properties</value>
  27. <value>classpath:conf/wx-mp.properties</value>
  28. <value>classpath:conf/wx-global.properties</value>
  29. <value>classpath:conf/pingan-pay.properties</value>
  30. <value>classpath:conf/oms-merch.properties</value>
  31. <value>classpath:conf/websocket.properties</value>
  32. <value>classpath:conf/print-ticket.properties</value>
  33. <value>classpath:conf/common.properties</value>
  34. <value>classpath:conf/fastdfs.properties</value>
  35. <value>classpath:conf/express-sf.properties</value>
  36. </list>
  37. </property>
  38. <property name="fileEncoding" value="UTF-8"/>
  39. </bean>
  40. <context:annotation-config/>
  41. <mvc:default-servlet-handler/>
  42. <aop:aspectj-autoproxy proxy-target-class="true"/>
  43. <mvc:annotation-driven>
  44. <mvc:message-converters register-defaults="true">
  45. <bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
  46. <property name="supportedMediaTypes">
  47. <list>
  48. <value>text/html;charset=UTF-8</value>
  49. <value>application/json;charset=UTF-8</value>
  50. </list>
  51. </property>
  52. <property name="features">
  53. <list>
  54. <value>WriteMapNullValue</value>
  55. <value>QuoteFieldNames</value>
  56. <value>WriteDateUseDateFormat</value>
  57. <!-- 禁用fastjson循环引用检测 -->
  58. <value>DisableCircularReferenceDetect</value>
  59. </list>
  60. </property>
  61. </bean>
  62. </mvc:message-converters>
  63. </mvc:annotation-driven>
  64. <tx:annotation-driven/>
  65. <!--<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource">
  66. <property name="driverClassName" value="${jdbc.driver}"/>
  67. <property name="jdbcUrl" value="${jdbc.url}"/>
  68. <property name="username" value="${jdbc.username}"/>
  69. <property name="password" value="${jdbc.password}"/>
  70. &lt;!&ndash; 队列中的最大等待数 &ndash;&gt;
  71. <property name="idleTimeout" value="${jdbc.idleTimeout}"/>
  72. &lt;!&ndash; the maximum lifetime of a connection in the pool &ndash;&gt;
  73. &lt;!&ndash; We strongly recommend setting this value,
  74. and it should be at least 30 seconds less than any database-level connection timeout. &ndash;&gt;
  75. <property name="maxLifetime" value="${jdbc.maxLifetime}"/>
  76. &lt;!&ndash; 最长等待时间,单位毫秒 &ndash;&gt;
  77. <property name="connectionTimeout" value="${jdbc.connectionTimeout}"/>
  78. &lt;!&ndash; 最大连接数 &ndash;&gt;
  79. <property name="maximumPoolSize" value="${jdbc.maximumPoolSize}"/>
  80. &lt;!&ndash; controls the maximum amount of time that a connection will be tested for aliveness.
  81. This value must be less than the connectionTimeout &ndash;&gt;
  82. <property name="validationTimeout" value="${jdbc.validationTimeout}"/>
  83. &lt;!&ndash; CAREFUL! THIS CONFIG IMPACTS SQL PERFORMANCE A LOT! &ndash;&gt;
  84. &lt;!&ndash;<property name="transactionIsolation" value="TRANSACTION_REPEATABLE_READ"/>&ndash;&gt;
  85. </bean>-->
  86. <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
  87. init-method="init" destroy-method="close">
  88. <property name="url">
  89. <value>${jdbc.url}</value>
  90. </property>
  91. <property name="username">
  92. <value>${jdbc.username}</value>
  93. </property>
  94. <property name="password">
  95. <value>${jdbc.password}</value>
  96. </property>
  97. <property name="initialSize">
  98. <value>${jdbc.initialSize}</value>
  99. </property>
  100. <property name="maxActive">
  101. <value>${jdbc.maxActive}</value>
  102. </property>
  103. <property name="proxyFilters">
  104. <list>
  105. <ref bean="stat-filter"/>
  106. <!--过滤永真条件 防止注入-->
  107. <ref bean="wall-filter"/>
  108. </list>
  109. </property>
  110. <property name="connectionInitSqls" value="set names utf8mb4;"/>
  111. <!--&lt;!&ndash; 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 &ndash;&gt;-->
  112. <property name="timeBetweenEvictionRunsMillis" value="60000" />
  113. <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
  114. <property name="minEvictableIdleTimeMillis" value="300000" />
  115. <!-- 建议配置为true,不影响性能,并且保证安全性。申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效 -->
  116. <property name="testWhileIdle" value="true" />
  117. <!-- 指定每个连接上PSCache的大小 -->
  118. <property name="maxPoolPreparedStatementPerConnectionSize" value="20" />
  119. </bean>
  120. <bean id="stat-filter" class="com.alibaba.druid.filter.stat.StatFilter">
  121. <property name="slowSqlMillis" value="1000"/>
  122. <property name="logSlowSql" value="true"/>
  123. <property name="mergeSql" value="true"/>
  124. </bean>
  125. <bean id="wall-filter" class="com.alibaba.druid.wall.WallFilter">
  126. <property name="dbType" value="mysql"/>
  127. <property name="config" ref="wall-filter-config"/>
  128. </bean>
  129. <bean id="wall-filter-config" class="com.alibaba.druid.wall.WallConfig">
  130. <property name="multiStatementAllow" value="true"/>
  131. </bean>
  132. <bean id="druid-stat-interceptor" class="com.alibaba.druid.support.spring.stat.DruidStatInterceptor"></bean>
  133. <bean id="druid-stat-pointcut" class="org.springframework.aop.support.JdkRegexpMethodPointcut" scope="prototype">
  134. <property name="patterns">
  135. <list>
  136. <value>com.kmall.framework.service.*</value>
  137. </list>
  138. </property>
  139. </bean>
  140. <aop:config>
  141. <aop:advisor advice-ref="druid-stat-interceptor" pointcut-ref="druid-stat-pointcut"/>
  142. </aop:config>
  143. <!-- 配置事务管理器 -->
  144. <bean id="transactionManager"
  145. class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  146. <property name="dataSource" ref="dataSource"></property>
  147. </bean>
  148. <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
  149. <property name="dataSource">
  150. <ref bean="dataSource"/>
  151. </property>
  152. </bean>
  153. <!-- JDBC配置 -->
  154. <bean id="namedParameterJdbcTemplate"
  155. class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate">
  156. <constructor-arg ref="dataSource"/>
  157. </bean>
  158. <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
  159. <property name="configLocation" value="classpath:mybatis.xml"/>
  160. <property name="mapperLocations" value="classpath:mybatis/mapper/**/*.xml"/>
  161. <property name="dataSource" ref="dataSource"/>
  162. </bean>
  163. <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
  164. <property name="basePackage" value="com.kmall.framework.dao"/>
  165. </bean>
  166. <bean id="restTemplate" class="org.springframework.web.client.RestTemplate"/>
  167. </beans>