applicationContext-test.xml 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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/servlet.properties</value>
  26. <value>classpath:conf/wx-mp.properties</value>
  27. <value>classpath:conf/wx-global.properties</value>
  28. <value>classpath:conf/pingan-pay.properties</value>
  29. <value>classpath:conf/oms-merch.properties</value>
  30. <value>classpath:conf/print-ticket.properties</value>
  31. <value>classpath:conf/common.properties</value>
  32. <value>classpath:conf/fastdfs.properties</value>
  33. </list>
  34. </property>
  35. <property name="fileEncoding" value="UTF-8"/>
  36. </bean>
  37. <context:annotation-config/>
  38. <mvc:default-servlet-handler/>
  39. <aop:aspectj-autoproxy proxy-target-class="true"/>
  40. <mvc:annotation-driven>
  41. <mvc:message-converters register-defaults="true">
  42. <bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
  43. <property name="supportedMediaTypes">
  44. <list>
  45. <value>text/html;charset=UTF-8</value>
  46. <value>application/json;charset=UTF-8</value>
  47. </list>
  48. </property>
  49. <property name="features">
  50. <list>
  51. <value>WriteMapNullValue</value>
  52. <value>QuoteFieldNames</value>
  53. <value>WriteDateUseDateFormat</value>
  54. <!-- 禁用fastjson循环引用检测 -->
  55. <value>DisableCircularReferenceDetect</value>
  56. </list>
  57. </property>
  58. </bean>
  59. </mvc:message-converters>
  60. </mvc:annotation-driven>
  61. <tx:annotation-driven/>
  62. <!--<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource">
  63. <property name="driverClassName" value="${jdbc.driver}"/>
  64. <property name="jdbcUrl" value="${jdbc.url}"/>
  65. <property name="username" value="${jdbc.username}"/>
  66. <property name="password" value="${jdbc.password}"/>
  67. &lt;!&ndash; 队列中的最大等待数 &ndash;&gt;
  68. <property name="idleTimeout" value="${jdbc.idleTimeout}"/>
  69. &lt;!&ndash; the maximum lifetime of a connection in the pool &ndash;&gt;
  70. &lt;!&ndash; We strongly recommend setting this value,
  71. and it should be at least 30 seconds less than any database-level connection timeout. &ndash;&gt;
  72. <property name="maxLifetime" value="${jdbc.maxLifetime}"/>
  73. &lt;!&ndash; 最长等待时间,单位毫秒 &ndash;&gt;
  74. <property name="connectionTimeout" value="${jdbc.connectionTimeout}"/>
  75. &lt;!&ndash; 最大连接数 &ndash;&gt;
  76. <property name="maximumPoolSize" value="${jdbc.maximumPoolSize}"/>
  77. &lt;!&ndash; controls the maximum amount of time that a connection will be tested for aliveness.
  78. This value must be less than the connectionTimeout &ndash;&gt;
  79. <property name="validationTimeout" value="${jdbc.validationTimeout}"/>
  80. &lt;!&ndash; CAREFUL! THIS CONFIG IMPACTS SQL PERFORMANCE A LOT! &ndash;&gt;
  81. &lt;!&ndash;<property name="transactionIsolation" value="TRANSACTION_REPEATABLE_READ"/>&ndash;&gt;
  82. </bean>-->
  83. <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
  84. init-method="init" destroy-method="close">
  85. <property name="url">
  86. <value>${jdbc.url}</value>
  87. </property>
  88. <property name="username">
  89. <value>${jdbc.username}</value>
  90. </property>
  91. <property name="password">
  92. <value>${jdbc.password}</value>
  93. </property>
  94. <property name="initialSize">
  95. <value>${jdbc.initialSize}</value>
  96. </property>
  97. <property name="maxActive">
  98. <value>${jdbc.maxActive}</value>
  99. </property>
  100. <property name="proxyFilters">
  101. <list>
  102. <ref bean="stat-filter"/>
  103. <!--过滤永真条件 防止注入-->
  104. <ref bean="wall-filter"/>
  105. </list>
  106. </property>
  107. <property name="connectionInitSqls" value="set names utf8mb4;"/>
  108. </bean>
  109. <bean id="stat-filter" class="com.alibaba.druid.filter.stat.StatFilter">
  110. <property name="slowSqlMillis" value="1000"/>
  111. <property name="logSlowSql" value="true"/>
  112. <property name="mergeSql" value="true"/>
  113. </bean>
  114. <bean id="wall-filter" class="com.alibaba.druid.wall.WallFilter">
  115. <property name="dbType" value="mysql"/>
  116. <property name="config" ref="wall-filter-config"/>
  117. </bean>
  118. <bean id="wall-filter-config" class="com.alibaba.druid.wall.WallConfig">
  119. <property name="multiStatementAllow" value="true"/>
  120. </bean>
  121. <bean id="druid-stat-interceptor" class="com.alibaba.druid.support.spring.stat.DruidStatInterceptor"></bean>
  122. <bean id="druid-stat-pointcut" class="org.springframework.aop.support.JdkRegexpMethodPointcut" scope="prototype">
  123. <property name="patterns">
  124. <list>
  125. <value>com.kmall.framework.service.*</value>
  126. </list>
  127. </property>
  128. </bean>
  129. <aop:config>
  130. <aop:advisor advice-ref="druid-stat-interceptor" pointcut-ref="druid-stat-pointcut"/>
  131. </aop:config>
  132. <!-- 配置事务管理器 -->
  133. <bean id="transactionManager"
  134. class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  135. <property name="dataSource" ref="dataSource"></property>
  136. </bean>
  137. <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
  138. <property name="dataSource">
  139. <ref bean="dataSource"/>
  140. </property>
  141. </bean>
  142. <!-- JDBC配置 -->
  143. <bean id="namedParameterJdbcTemplate"
  144. class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate">
  145. <constructor-arg ref="dataSource"/>
  146. </bean>
  147. <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
  148. <property name="configLocation" value="classpath:mybatis.xml"/>
  149. <property name="mapperLocations" value="classpath:mybatis/mapper/**/*.xml"/>
  150. <property name="dataSource" ref="dataSource"/>
  151. </bean>
  152. <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
  153. <property name="basePackage" value="com.kmall.framework.dao"/>
  154. </bean>
  155. <bean id="restTemplate" class="org.springframework.web.client.RestTemplate"/>
  156. </beans>