|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
|
|
|
xmlns:context="http://www.springframework.org/schema/context"
|
|
|
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
|
|
|
xmlns:mybatis="http://mybatis.org/schema/mybatis-spring"
|
|
|
|
|
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
|
|
http://www.springframework.org/schema/beans/spring-beans.xsd
|
|
|
http://www.springframework.org/schema/mvc
|
|
|
http://www.springframework.org/schema/mvc/spring-mvc.xsd
|
|
|
|
|
|
http://www.springframework.org/schema/tx
|
|
|
http://www.springframework.org/schema/tx/spring-tx.xsd
|
|
|
|
|
|
http://www.springframework.org/schema/context
|
|
|
http://www.springframework.org/schema/context/spring-context.xsd
|
|
|
http://www.springframework.org/schema/aop
|
|
|
http://www.springframework.org/schema/aop/spring-aop.xsd
|
|
|
http://mybatis.org/schema/mybatis-spring
|
|
|
http://mybatis.org/schema/mybatis-spring.xsd">
|
|
|
|
|
|
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
|
|
|
|
|
|
<property name="driverClassName" value="${base.driverClassName}" />
|
|
|
<property name="url" value="${base.url}" />
|
|
|
<property name="username" value="${base.username}" />
|
|
|
<property name="password" value="${base.password}" />
|
|
|
|
|
|
|
|
|
<property name="initialSize" value="${base.initialSize}" />
|
|
|
<property name="maxActive" value="${base.maxActive}" />
|
|
|
<property name="minIdle" value="${base.minIdle}" />
|
|
|
<property name="maxWait" value="${base.maxWait}" />
|
|
|
|
|
|
|
|
|
<property name="validationQuery" value="${base.validationQuery}" />
|
|
|
<property name="testOnBorrow" value="${base.testOnBorrow}" />
|
|
|
<property name="testOnReturn" value="${base.testOnReturn}" />
|
|
|
<property name="testWhileIdle" value="${base.testWhileIdle}" />
|
|
|
|
|
|
<property name="timeBetweenEvictionRunsMillis" value="${base.timeBetweenEvictionRunsMillis}" />
|
|
|
<property name="minEvictableIdleTimeMillis" value="${base.minEvictableIdleTimeMillis}" />
|
|
|
|
|
|
<property name="removeAbandoned" value="${base.removeAbandoned}" />
|
|
|
<property name="removeAbandonedTimeout" value="${base.removeAbandonedTimeout}" />
|
|
|
<property name="logAbandoned" value="${base.logAbandoned}" />
|
|
|
<!-- <property name="connectionProperties" value="config.decrypt=true;config.decrypt.key=${base.publickey}"/>
|
|
|
<property name="filters" value="${base.filters}" /> -->
|
|
|
</bean>
|
|
|
|
|
|
<!-- 配置druid监控spring jdbc -->
|
|
|
<bean id="druid-stat-interceptor"
|
|
|
class="com.alibaba.druid.support.spring.stat.DruidStatInterceptor">
|
|
|
</bean>
|
|
|
<bean id="druid-stat-pointcut" class="org.springframework.aop.support.JdkRegexpMethodPointcut"
|
|
|
scope="prototype">
|
|
|
<property name="patterns">
|
|
|
<list>
|
|
|
<value>com.huatek.frame.base.service.*</value>
|
|
|
</list>
|
|
|
</property>
|
|
|
</bean>
|
|
|
<aop:config>
|
|
|
<aop:advisor advice-ref="druid-stat-interceptor"
|
|
|
pointcut-ref="druid-stat-pointcut" />
|
|
|
</aop:config>
|
|
|
|
|
|
<bean id="transactionManager"
|
|
|
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
|
|
<property name="dataSource" ref="dataSource" />
|
|
|
</bean>
|
|
|
|
|
|
<!-- 声明式事务 -->
|
|
|
<tx:annotation-driven transaction-manager="transactionManager"
|
|
|
proxy-target-class="true" />
|
|
|
|
|
|
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
|
|
|
<property name="dataSource" ref="dataSource" />
|
|
|
<property name="configLocation" value="classpath:mybatis-config.xml"></property>
|
|
|
|
|
|
<property name="mapperLocations">
|
|
|
<array>
|
|
|
<value>classpath:com/huatek/frame/base/mapping/*Mapper.xml</value>
|
|
|
<value>classpath:com/huatek/torch/sql/mapping/*Mapper.xml</value>
|
|
|
</array>
|
|
|
</property>
|
|
|
|
|
|
<!-- 配置mybatis分页插件PageHelper -->
|
|
|
<property name="plugins">
|
|
|
<array>
|
|
|
<bean class="com.github.pagehelper.PageInterceptor">
|
|
|
<property name="properties">
|
|
|
<value>reasonable=true</value>
|
|
|
</property>
|
|
|
</bean>
|
|
|
</array>
|
|
|
</property>
|
|
|
|
|
|
</bean>
|
|
|
|
|
|
<!-- sqlSessionTemplate配置 和org.mybatis.spring.mapper.MapperScannerConfigurer可以共存-->
|
|
|
<bean name="sqlSessionTemplate" id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
|
|
|
<constructor-arg index="0" ref="sqlSessionFactory" />
|
|
|
</bean>
|
|
|
|
|
|
<!-- 注册Mapper方式二:也可不指定特定mapper,而使用自动扫描包的方式来注册各种Mapper ,配置如下: -->
|
|
|
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
|
|
|
|
|
|
<property name="annotationClass" value="org.springframework.stereotype.Repository" />
|
|
|
<property name="basePackage" value="com.huatek.frame.base.mapper" />
|
|
|
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
|
|
|
</bean>
|
|
|
</beans> |