applicationContext-test.xml 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. <!-- 2021-12-15改为配置类:com.kmall.admin.config.datasource.DataSourceConfig-->
  87. <!--<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
  88. init-method="init" destroy-method="close">
  89. <property name="url">
  90. <value>${jdbc.url}</value>
  91. </property>
  92. <property name="username">
  93. <value>${jdbc.username}</value>
  94. </property>
  95. <property name="password">
  96. <value>${jdbc.password}</value>
  97. </property>
  98. <property name="initialSize">
  99. <value>${jdbc.initialSize}</value>
  100. </property>
  101. <property name="maxActive">
  102. <value>${jdbc.maxActive}</value>
  103. </property>
  104. <property name="proxyFilters">
  105. <list>
  106. <ref bean="stat-filter"/>
  107. &lt;!&ndash;过滤永真条件 防止注入&ndash;&gt;
  108. <ref bean="wall-filter"/>
  109. </list>
  110. </property>
  111. <property name="connectionInitSqls" value="set names utf8mb4;"/>
  112. &lt;!&ndash;&lt;!&ndash; 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 &ndash;&gt;&ndash;&gt;
  113. <property name="timeBetweenEvictionRunsMillis" value="60000" />
  114. &lt;!&ndash; 配置一个连接在池中最小生存的时间,单位是毫秒 &ndash;&gt;
  115. <property name="minEvictableIdleTimeMillis" value="300000" />
  116. &lt;!&ndash; 建议配置为true,不影响性能,并且保证安全性。申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效 &ndash;&gt;
  117. <property name="testWhileIdle" value="true" />
  118. &lt;!&ndash; 指定每个连接上PSCache的大小 &ndash;&gt;
  119. <property name="maxPoolPreparedStatementPerConnectionSize" value="20" />
  120. </bean>-->
  121. <!--<bean id="stat-filter" class="com.alibaba.druid.filter.stat.StatFilter">
  122. <property name="slowSqlMillis" value="1000"/>
  123. <property name="logSlowSql" value="true"/>
  124. <property name="mergeSql" value="true"/>
  125. </bean>-->
  126. <!--<bean id="wall-filter" class="com.alibaba.druid.wall.WallFilter">
  127. <property name="dbType" value="mysql"/>
  128. <property name="config" ref="wall-filter-config"/>
  129. </bean>-->
  130. <!--<bean id="wall-filter-config" class="com.alibaba.druid.wall.WallConfig">
  131. <property name="multiStatementAllow" value="true"/>
  132. </bean>-->
  133. <bean id="druid-stat-interceptor" class="com.alibaba.druid.support.spring.stat.DruidStatInterceptor"></bean>
  134. <bean id="druid-stat-pointcut" class="org.springframework.aop.support.JdkRegexpMethodPointcut" scope="prototype">
  135. <property name="patterns">
  136. <list>
  137. <value>com.kmall.framework.service.*</value>
  138. </list>
  139. </property>
  140. </bean>
  141. <aop:config>
  142. <aop:advisor advice-ref="druid-stat-interceptor" pointcut-ref="druid-stat-pointcut"/>
  143. </aop:config>
  144. <!-- 配置事务管理器 -->
  145. <bean id="transactionManager"
  146. class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  147. <property name="dataSource" ref="dataSource"></property>
  148. </bean>
  149. <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
  150. <property name="dataSource">
  151. <ref bean="dataSource"/>
  152. </property>
  153. </bean>
  154. <!-- JDBC配置 -->
  155. <bean id="namedParameterJdbcTemplate"
  156. class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate">
  157. <constructor-arg ref="dataSource"/>
  158. </bean>
  159. <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
  160. <property name="configLocation" value="classpath:mybatis.xml"/>
  161. <property name="mapperLocations" value="classpath:mybatis/mapper/**/*.xml"/>
  162. <property name="dataSource" ref="dataSource"/>
  163. </bean>
  164. <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
  165. <property name="basePackage" value="com.kmall.framework.dao"/>
  166. </bean>
  167. <bean id="restTemplate" class="org.springframework.web.client.RestTemplate"/>
  168. </beans>