1
0

applicationContext-test.xml 8.8 KB

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