141 lines
6.6 KiB
XML
141 lines
6.6 KiB
XML
<?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:p="http://www.springframework.org/schema/p"
|
||
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
|
||
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"
|
||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
|
||
http://www.springframework.org/schema/context
|
||
http://www.springframework.org/schema/context/spring-context-4.1.xsd
|
||
http://www.springframework.org/schema/tx
|
||
http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
|
||
http://www.springframework.org/schema/aop
|
||
http://www.springframework.org/schema/aop/spring-aop-4.1.xsd
|
||
http://www.springframework.org/schema/mvc
|
||
http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd" default-lazy-init="true">
|
||
<import resource="activiti.cfg.xml"/>
|
||
<!-- 自动扫描 -->
|
||
<context:component-scan base-package="com.sipai" />
|
||
<!-- 引入配置文件 -->
|
||
<bean id="propertyConfigurer"
|
||
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||
<property name="location" value="classpath:db.properties" />
|
||
</bean>
|
||
|
||
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
|
||
destroy-method="close">
|
||
<property name="driverClassName" value="${driver}" />
|
||
<property name="url" value="${url}" />
|
||
<property name="username" value="${username}" />
|
||
<property name="password" value="${password}" />
|
||
|
||
<!-- 初始化连接大小 -->
|
||
<property name="initialSize" value="5"></property>
|
||
<!-- 连接池最大连接数-->
|
||
<property name="maxActive" value="15"></property>
|
||
<!-- 连接池最大空闲数 -->
|
||
<property name="maxIdle" value="10"></property>
|
||
<!-- 连接池最小空闲数 -->
|
||
<property name="minIdle" value="5"></property>
|
||
<!-- 获取连接最大等待时间,以毫秒为单位. -->
|
||
<property name="maxWait" value="30000"></property>
|
||
|
||
<!-- 设置在自动回收超时连接的时候打印连接的超时错误 -->
|
||
<property name="logAbandoned" value="true"/>
|
||
<!-- 设置自动回收超时连接 -->
|
||
<property name="removeAbandoned" value="true"/>
|
||
<!-- 自动回收超时时间(以秒数为单位) -->
|
||
<property name="removeAbandonedTimeout" value="180"/>
|
||
|
||
<!-- 连接在池中保持空闲而不被空闲连接回收器线程,以毫秒为单位.-->
|
||
<property name="minEvictableIdleTimeMillis" value="1800000" />
|
||
<!-- 在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位. -->
|
||
<property name="timeBetweenEvictionRunsMillis" value="600000" />
|
||
<!-- 在每次空闲连接回收器线程(如果有)运行时检查的连接数量 -->
|
||
<property name="numTestsPerEvictionRun" value="10"/>
|
||
|
||
<!-- SQL查询,用来验证从连接池取出的连接,在将连接返回给调用者之前.如果指定,则查询必须是一个SQL SELECT并且必须返回至少一行记录 -->
|
||
<!-- <property name="validationQuery">
|
||
<value>SELECT 1</value>
|
||
</property> -->
|
||
<!-- 指明是否在从池中取出连接前进行检验,如果检验失败,则从池中去除连接并尝试取出另一个. -->
|
||
<!-- <property name="testOnBorrow">
|
||
<value>true</value>
|
||
</property> -->
|
||
</bean>
|
||
|
||
|
||
|
||
<!-- spring和MyBatis整合 -->
|
||
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
|
||
<property name="dataSource" ref="dataSource" />
|
||
<!-- 自动扫描mapping.xml文件 -->
|
||
<property name="mapperLocations">
|
||
<array>
|
||
<value>classpath*:com/sipai/mapper/**/*.xml</value>
|
||
</array>
|
||
</property>
|
||
<!-- 翻页功能 -->
|
||
<property name="plugins">
|
||
<array>
|
||
<bean class="com.github.pagehelper.PageHelper">
|
||
<property name="properties">
|
||
<value>
|
||
dialect=sqlserver
|
||
reasonable=true
|
||
</value>
|
||
</property>
|
||
</bean>
|
||
</array>
|
||
</property>
|
||
</bean>
|
||
|
||
<!-- 获取sqlSession, 用于commDao的实现-->
|
||
<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
|
||
<constructor-arg index="0" ref="sqlSessionFactory"/>
|
||
</bean>
|
||
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
|
||
<property name="basePackage" value="com.sipai.mapper" />
|
||
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
|
||
</bean>
|
||
<!-- (事务管理)transaction manager, use JtaTransactionManager for global tx -->
|
||
<bean id="transactionManager"
|
||
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
||
<property name="dataSource" ref="dataSource" />
|
||
</bean>
|
||
<!-- enable transaction annotation support -->
|
||
<tx:annotation-driven transaction-manager="transactionManager" />
|
||
<!-- 需要将流程引擎的事务托管给spring统一管理 -->
|
||
<tx:advice id="txAdvice" transaction-manager="transactionManager">
|
||
<tx:attributes>
|
||
<tx:method name="start*" propagation="REQUIRED"/>
|
||
<tx:method name="execute*" propagation="REQUIRED"/>
|
||
<tx:method name="save*" propagation="REQUIRED"/>
|
||
<tx:method name="delete*" propagation="REQUIRED" />
|
||
<tx:method name="update*" propagation="REQUIRED" />
|
||
<tx:method name="remove*" propagation="REQUIRED" />
|
||
<tx:method name="assign*" propagation="REQUIRED" />
|
||
<tx:method name="create*" propagation="REQUIRED" />
|
||
<tx:method name="complete*" propagation="REQUIRED" />
|
||
<tx:method name="finish*" propagation="REQUIRED" />
|
||
<tx:method name="terminate*" propagation="REQUIRED" />
|
||
<tx:method name="take*" propagation="REQUIRED" />
|
||
<tx:method name="deploy*" propagation="REQUIRED" />
|
||
<tx:method name="undeploy*" propagation="REQUIRED" />
|
||
<tx:method name="redeploy*" propagation="REQUIRED" />
|
||
|
||
<tx:method name="get*" propagation="REQUIRED" read-only="true" />
|
||
<tx:method name="find*" propagation="REQUIRED" read-only="true" />
|
||
<tx:method name="query*" propagation="REQUIRED" read-only="true" />
|
||
<tx:method name="search*" propagation="REQUIRED" read-only="true" />
|
||
<tx:method name="is*" propagation="REQUIRED" read-only="true" />
|
||
<tx:method name="*" propagation="REQUIRED" />
|
||
</tx:attributes>
|
||
</tx:advice>
|
||
<aop:config>
|
||
<aop:pointcut id="transactionPointcut" expression="execution(public * com.sipai.service.*.*(..))" />
|
||
<aop:advisor pointcut-ref="transactionPointcut"
|
||
advice-ref="txAdvice" />
|
||
</aop:config>
|
||
<aop:aspectj-autoproxy proxy-target-class="true" />
|
||
</beans> |