spring-mybatis.xml 3.0 KB
<?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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:util="http://www.springframework.org/schema/util"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.2.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
    http://www.springframework.org/schema/util
    http://www.springframework.org/schema/util/spring-util-3.2.xsd">
	
	<!-- mybatis文件配置,扫描所有mapper文件 -->
	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"
		p:dataSource-ref="dynamicDataSource" p:configLocation="classpath:mybatis-config.xml"
		p:mapperLocations="classpath:mapper/*.xml" /><!-- configLocation为mybatis属性 
		mapperLocations为所有mapper -->

	<!-- spring与mybatis整合配置,扫描所有dao -->
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"
		p:basePackage="com.sibu.orderHelper.base.dao" p:sqlSessionFactoryBeanName="sqlSessionFactory" />
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"
		p:basePackage="com.sibu.orderHelper.integral.web.dao" p:sqlSessionFactoryBeanName="sqlSessionFactory" />

	<!-- 对数据源进行事务管理 -->
	<!-- <bean id="transactionManager"
		class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
		p:dataSource-ref="dynamicDataSource" /> -->

	<!-- 事务注解驱动,标注@Transactional的类和方法将具有事务性 -->  
	<!-- <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/> -->
	
	<!-- 配置事务的传播特性 
	<tx:advice id="txAdvice" transaction-manager="transactionManager">
		<tx:attributes>
			<tx:method name="add*" propagation="REQUIRED" read-only="false"
				rollback-for="Exception" />
			<tx:method name="delete*" propagation="REQUIRED" read-only="false"
				rollback-for="Exception" />
			<tx:method name="edit*" propagation="REQUIRED" read-only="false"
				rollback-for="Exception" />
			<tx:method name="proc*" propagation="REQUIRED" read-only="false"
				rollback-for="Exception" />
			<tx:method name="list*" read-only="true" />
			<tx:method name="*" read-only="false" />
		</tx:attributes>
	</tx:advice>-->
	<!-- 那些类的哪些方法参与事务 -->
	<!-- <aop:config>
		<aop:pointcut id="allManagerMethod" expression="execution(* com.sibu.orderHelper.integral.service.*.*(..))" />
		<aop:advisor pointcut-ref="allManagerMethod" advice-ref="txAdvice" />
	</aop:config> -->
</beans>