spring-mybatis.xml
3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?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.dao" p:sqlSessionFactoryBeanName="sqlSessionFactory"/>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"
p:basePackage="com.sibu.orderHelper.hotel.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" mode="proxy"/>-->
<!-- 配置事务的传播特性 -->
<!--<tx:advice id="txAdvice" transaction-manager="transactionManager">-->
<!--<tx:attributes>-->
<!--<tx:method name="*" isolation="DEFAULT" rollback-for="java.lang.Exception" read-only="false" timeout="-1"-->
<!--propagation="NEVER"/>-->
<!--</tx:attributes>-->
<!--</tx:advice>-->
<!-- <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" pro/>
</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>