applicationContext-test.xml 7.9 KB

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