|
@@ -95,113 +95,10 @@
|
|
|
</array>
|
|
|
</property>
|
|
|
</bean>
|
|
|
-
|
|
|
- <!-- 注入配置 -->
|
|
|
- <bean id="globalConfig" class="com.baomidou.mybatisplus.entity.GlobalConfiguration">
|
|
|
- <property name="sqlInjector" ref="sqlInjector" />
|
|
|
- </bean>
|
|
|
- <bean id="sqlInjector" class="com.baomidou.mybatisplus.test.mysql.MySqlInjector" />
|
|
|
-
|
|
|
- <bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
|
|
|
- <property name="basePackage" value="com.baomidou.mybatisplus.test.mysql.mapper;com.baomidou.mybatisplus.test.plugin.OptimisticLocker.mapper" />
|
|
|
- </bean>
|
|
|
-<?xml version="1.0" encoding="UTF-8"?>
|
|
|
-<beans xmlns="http://www.springframework.org/schema/beans"
|
|
|
- xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
|
|
|
- xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
|
|
|
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
|
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
|
|
|
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
|
|
|
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
|
|
|
- http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">
|
|
|
-
|
|
|
- <!-- 加载配置文件 -->
|
|
|
- <context:property-placeholder location="classpath:properties/jdbc.properties" />
|
|
|
-
|
|
|
- <!-- 数据库连接池 -->
|
|
|
- <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
|
|
|
- destroy-method="close">
|
|
|
- <property name="url" value="${jdbc.url}" />
|
|
|
- <property name="username" value="${jdbc.username}" />
|
|
|
- <property name="password" value="${jdbc.password}" />
|
|
|
- <property name="driverClassName" value="${jdbc.driver}" />
|
|
|
- <!-- 初始化连接大小 -->
|
|
|
- <property name="initialSize" value="0" />
|
|
|
- <!-- 连接池最大使用连接数量 -->
|
|
|
- <property name="maxActive" value="20" />
|
|
|
- <!-- 连接池最大空闲 -->
|
|
|
- <property name="maxIdle" value="20" />
|
|
|
- <!-- 连接池最小空闲 -->
|
|
|
- <property name="minIdle" value="0" />
|
|
|
- <!-- 获取连接最大等待时间 -->
|
|
|
- <property name="maxWait" value="60000" />
|
|
|
- <property name="validationQuery" value="${validationQuery}" />
|
|
|
- <property name="testOnBorrow" value="false" />
|
|
|
- <property name="testOnReturn" value="false" />
|
|
|
- <property name="testWhileIdle" value="true" />
|
|
|
- <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
|
|
|
- <property name="timeBetweenEvictionRunsMillis" value="60000" />
|
|
|
- <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
|
|
|
- <property name="minEvictableIdleTimeMillis" value="25200000" />
|
|
|
- <!-- 打开removeAbandoned功能 -->
|
|
|
- <property name="removeAbandoned" value="true" />
|
|
|
- <!-- 1800秒,也就是30分钟 -->
|
|
|
- <property name="removeAbandonedTimeout" value="1800" />
|
|
|
- <!-- 关闭abanded连接时输出错误日志 -->
|
|
|
- <property name="logAbandoned" value="true" />
|
|
|
- <!-- 监控数据库 -->
|
|
|
- <property name="filters" value="stat" />
|
|
|
- </bean>
|
|
|
-
|
|
|
- <!-- 事务管理器 -->
|
|
|
- <bean id="transactionManager"
|
|
|
- class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
|
|
- <!-- 数据源 -->
|
|
|
- <property name="dataSource" ref="dataSource" />
|
|
|
- </bean>
|
|
|
-
|
|
|
- <!-- 通知 -->
|
|
|
- <tx:advice id="txAdvice" transaction-manager="transactionManager">
|
|
|
- <tx:attributes>
|
|
|
- <!-- 传播行为 -->
|
|
|
- <tx:method name="save*" propagation="REQUIRED" />
|
|
|
- <tx:method name="insert*" propagation="REQUIRED" />
|
|
|
- <tx:method name="add*" propagation="REQUIRED" />
|
|
|
- <tx:method name="create*" propagation="REQUIRED" />
|
|
|
- <tx:method name="delete*" propagation="REQUIRED" />
|
|
|
- <tx:method name="update*" propagation="REQUIRED" />
|
|
|
- <tx:method name="find*" propagation="SUPPORTS" read-only="true" />
|
|
|
- <tx:method name="select*" propagation="SUPPORTS" read-only="true" />
|
|
|
- <tx:method name="get*" propagation="SUPPORTS" read-only="true" />
|
|
|
- </tx:attributes>
|
|
|
- </tx:advice>
|
|
|
- <!-- 切面 -->
|
|
|
- <aop:config>
|
|
|
- <aop:advisor advice-ref="txAdvice"
|
|
|
- pointcut="execution(* com.baomidou.*.service.*.*.*(..))" />
|
|
|
- </aop:config>
|
|
|
-
|
|
|
- <!-- MyBatis SqlSessionFactoryBean 配置 -->
|
|
|
- <bean id="sqlSessionFactory"
|
|
|
- class="com.baomidou.mybatisplus.spring.MybatisSqlSessionFactoryBean">
|
|
|
- <property name="dataSource" ref="dataSource" />
|
|
|
- <property name="configLocation" value="classpath:mybatis-config.xml" />
|
|
|
- <property name="typeAliasesPackage" value="com.baomidou.mybatisplus.test.mysql.entity;com.baomidou.mybatisplus.test.plugin.OptimisticLocker.entity" />
|
|
|
- <property name="mapperLocations" value="classpath:mysql/*Mapper.xml" />
|
|
|
- <property name="globalConfig" ref="globalConfig" />
|
|
|
- <property name="plugins">
|
|
|
- <array>
|
|
|
- <!-- 分页插件配置 -->
|
|
|
- <bean id="paginationInterceptor"
|
|
|
- class="com.baomidou.mybatisplus.plugins.PaginationInterceptor">
|
|
|
- <property name="dialectType" value="mysql" />
|
|
|
- </bean>
|
|
|
- <bean id="optimisticLockerInterceptor"
|
|
|
- class="com.baomidou.mybatisplus.plugins.OptimisticLockerInterceptor">
|
|
|
- </bean>
|
|
|
- </array>
|
|
|
- </property>
|
|
|
- </bean>
|
|
|
+
|
|
|
+ <bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
|
|
|
+ <constructor-arg index="0" ref="sqlSessionFactory"/>
|
|
|
+ </bean>
|
|
|
|
|
|
<!-- 注入配置 -->
|
|
|
<bean id="globalConfig" class="com.baomidou.mybatisplus.entity.GlobalConfiguration">
|