初始化
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
8.3 KiB

  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"
  6. xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"
  7. xmlns:aop="http://www.springframework.org/schema/aop"
  8. xsi:schemaLocation="http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring-1.2.xsd
  9. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  10. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
  11. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
  12. <aop:config proxy-target-class="true"/>
  13. <context:annotation-config/>
  14. <!--<task:annotation-driven executor="permissionUpdateExecutor"/>-->
  15. <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  16. <property name="locations">
  17. <list>
  18. <value>classpath:application.properties</value>
  19. </list>
  20. </property>
  21. </bean>
  22. <bean id="dataSource" destroy-method="close" class="com.sie.iot.common.dbcp.BasicDataSourceDecrypt">
  23. <property name="driverClassName" value="${properties.jdbc.driverClassName}"/>
  24. <property name="url" value="${properties.jdbc.url}"/>
  25. <property name="username" value="${properties.jdbc.username}"/>
  26. <property name="password" value="${properties.jdbc.password}"/>
  27. <property name="validationQuery" value="${properties.jdbc.validationQuery}"/>
  28. <property name="initialSize" value="${properties.jdbc.initialSize}"/>
  29. <property name="maxActive" value="${properties.jdbc.maxActive}"/>
  30. <property name="maxIdle" value="${properties.jdbc.maxIdle}"/>
  31. <property name="minIdle" value="${properties.jdbc.minIdle}"/>
  32. </bean>
  33. <!-- 事务管理器 -->
  34. <bean id="dataSourceTransactionManager"
  35. class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  36. <property name="dataSource" ref="dataSource"></property>
  37. </bean>
  38. <!-- 基于注解的事务管理 -->
  39. <tx:annotation-driven transaction-manager="dataSourceTransactionManager"/>
  40. <!--配置sqlSessionTemplate:通过带参数的构造方法创建对象 -->
  41. <bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
  42. <!-- 以sqlSessionFactory为参数传入构造函数中 -->
  43. <constructor-arg ref="sqlSessionFactoryBean"/>
  44. <!-- mybatis执行器,取值范围是SIMPLE/REUSE/BATCH三种类型 -->
  45. <constructor-arg value="BATCH"/>
  46. </bean>
  47. <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
  48. <property name="dataSource" ref="dataSource"></property>
  49. </bean>
  50. <!-- 配置SqlSessionFactoryBean
  51. Mybatis提供的: org.mybatis.spring.SqlSessionFactoryBean
  52. MP提供的:com.baomidou.mybatisplus.spring.MybatisSqlSessionFactoryBean
  53. -->
  54. <bean id="sqlSessionFactoryBean" class="com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean">
  55. <!-- 数据源 -->
  56. <property name="dataSource" ref="dataSource"></property>
  57. <property name="configLocation" value="classpath:com/yuexiu/secp/comm/config/mybatis-config.xml"></property>
  58. <!-- 别名处理 -->
  59. <!-- <property name="typeAliasesPackage" value="com.atguigu.mp.beans"></property>-->
  60. <!-- 注入全局MP策略配置 -->
  61. <property name="globalConfig" ref="globalConfiguration"></property>
  62. <!-- 插件注册 -->
  63. <property name="plugins">
  64. <list>
  65. <!-- 注册分页插件 -->
  66. <!--<bean class="com.baomidou.mybatisplus.plugins.PaginationInterceptor"></bean>-->
  67. <bean class="com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor"></bean>
  68. <!-- 注册执行分析插件 -->
  69. <bean class="com.baomidou.mybatisplus.extension.plugins.SqlExplainInterceptor">
  70. <!--<property name="stopProceed" value="true"></property>-->
  71. </bean>
  72. <!-- 注册性能分析插件 -->
  73. <!-- <bean class="com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor">
  74. <property name="format" value="true"></property>
  75. &lt;!&ndash; <property name="maxTime" value="5"></property> &ndash;&gt;
  76. </bean>-->
  77. <!-- 注册乐观锁插件 -->
  78. <bean class="com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor">
  79. </bean>
  80. </list>
  81. </property>
  82. </bean>
  83. <!-- 定义MybatisPlus的全局策略配置-->
  84. <!--<bean id ="globalConfiguration" class="com.baomidou.mybatisplus.entity.GlobalConfiguration">-->
  85. <bean id="globalConfiguration" class="com.baomidou.mybatisplus.core.config.GlobalConfig">
  86. <!-- 在2.3版本以后,dbColumnUnderline 默认值就是true -->
  87. <!--<property name="dbColumnUnderline" value="true"></property>-->
  88. <!-- 全局的主键策略 -->
  89. <!--<property name="idType" value="0"></property>-->
  90. <!-- 全局的表前缀策略配置 -->
  91. <!--<property name="tablePrefix" value="tbl_"></property>-->
  92. <!--自定义填充策略接口实现-->
  93. <property name="metaObjectHandler" ref="myMetaObjectHandler"/>
  94. <property name="identifierGenerator" ref="customIdGenerator"/>
  95. </bean>
  96. <!-- 公共字段填充 处理器 -->
  97. <bean id="myMetaObjectHandler" class="com.siefw.hibernate.core.handler.ModelMetaObjectHandler"></bean>
  98. <bean name="customIdGenerator" class="com.sie.iot.common.idgenerate.CustomerIdGenerator"/>
  99. <!--
  100. 配置mybatis 扫描mapper接口的路径
  101. -->
  102. <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
  103. <property name="basePackage"
  104. value="com.sie.demo.comm.model.dao,com.sie.iot.base.model.dao"></property>
  105. </bean>
  106. <!-- 配置事务的传播特性 -->
  107. <tx:advice id="txAdvice" transaction-manager="dataSourceTransactionManager">
  108. <tx:attributes>
  109. <tx:method name="insert*" propagation="REQUIRED" rollback-for="Exception"/>
  110. <tx:method name="save*" propagation="REQUIRED" rollback-for="Exception"/>
  111. <tx:method name="update*" propagation="REQUIRED" rollback-for="Exception"/>
  112. <tx:method name="delete*" propagation="REQUIRED" rollback-for="Exception"/>
  113. <tx:method name="remove*" propagation="REQUIRED" rollback-for="Exception"/>
  114. <tx:method name="relesae*" propagation="REQUIRED" rollback-for="Exception" read-only="false"/>
  115. <tx:method name="send*" propagation="REQUIRED" rollback-for="Exception" read-only="false"/>
  116. <tx:method name="set*" propagation="REQUIRED" rollback-for="Exception" read-only="false"/>
  117. <tx:method name="find*" read-only="true"/>
  118. <tx:method name="get*" read-only="true"/>
  119. <tx:method name="*" read-only="true"/>
  120. </tx:attributes>
  121. </tx:advice>
  122. <!-- 那些类的哪些方法参与事务 -->
  123. <aop:config><!--|| execution(* com.sie.saaf.*.model.dao.readonly.*.*(..))-->
  124. <aop:pointcut id="businessService" expression="execution(* com.yuexiu.secp.comm.model.service.impl.*.*(..))
  125. || execution(* com.sie.iot.common.model.inter.server.*.*(..))
  126. || execution(* com.sie.iot.base.model.inter.server.*.*(..))"/>
  127. <aop:advisor advice-ref="txAdvice" pointcut-ref="businessService" order="0"/>
  128. </aop:config>
  129. <bean id="messageResource" class="org.springframework.context.support.ResourceBundleMessageSource">
  130. <property name="defaultEncoding" value="UTF-8"></property>
  131. <property name="cacheSeconds" value="0"></property>
  132. <property name="basenames">
  133. <list>
  134. <value>config.common</value>
  135. <value>config.2069-siedemo-comm-application</value>
  136. </list>
  137. </property>
  138. </bean>
  139. </beans>