spring-mybatis.xml
8.9 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?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"/>-->
<!-- begin 新系统mall -->
<bean id="mallReadDataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
<!-- 基本属性 url、user、password -->
<property name="url" value="${mall.read.url}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true" />
<property name="username" value="${mall.read.username}" />
<property name="password" value="${mall.read.password}" />
<!-- 配置初始化大小、最小、最大 -->
<property name="initialSize" value="1"/>
<property name="minIdle" value="1"/>
<property name="maxActive" value="200"/>
<!-- 配置获取连接等待超时的时间 -->
<property name="maxWait" value="60000"/>
<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
<property name="timeBetweenEvictionRunsMillis" value="60000"/>
<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
<property name="minEvictableIdleTimeMillis" value="300000"/>
<property name="validationQuery" value="SELECT 'x'"/>
<property name="testWhileIdle" value="true"/>
<property name="testOnBorrow" value="false"/>
<property name="testOnReturn" value="false"/>
<!-- 打开PSCache,并且指定每个连接上PSCache的大小 -->
<property name="poolPreparedStatements" value="true"/>
<property name="maxPoolPreparedStatementPerConnectionSize" value="20"/>
<!-- 配置监控统计拦截的filters -->
<property name="filters" value="stat"/>
</bean>
<bean id="mallReadSqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="mapperLocations" value="classpath:mall-mapper/**/read/**/*.xml" />
<!--<property name="typeAliasesPackage" value="com.ejavashop.entity" />-->
<property name="configLocation" value="classpath:mybatis-config.xml"></property>
<property name="dataSource" ref="mallReadDataSource"/>
</bean>
<bean name="mallReadMapperScanner" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.sibu.orderHelper.mall.*.read" />
<property name="sqlSessionFactoryBeanName" value="mallReadSqlSessionFactory" />
</bean>
<bean id="mallWriteDataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
<!-- 基本属性 url、user、password -->
<property name="url" value="${mall.write.url}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true" />
<property name="username" value="${mall.write.username}" />
<property name="password" value="${mall.write.password}" />
<!-- 配置初始化大小、最小、最大 -->
<property name="initialSize" value="1"/>
<property name="minIdle" value="1"/>
<property name="maxActive" value="200"/>
<!-- 配置获取连接等待超时的时间 -->
<property name="maxWait" value="60000"/>
<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
<property name="timeBetweenEvictionRunsMillis" value="60000"/>
<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
<property name="minEvictableIdleTimeMillis" value="300000"/>
<property name="validationQuery" value="SELECT 'x'"/>
<property name="testWhileIdle" value="true"/>
<property name="testOnBorrow" value="false"/>
<property name="testOnReturn" value="false"/>
<!-- 打开PSCache,并且指定每个连接上PSCache的大小 -->
<property name="poolPreparedStatements" value="true"/>
<property name="maxPoolPreparedStatementPerConnectionSize" value="20"/>
<!-- 配置监控统计拦截的filters -->
<property name="filters" value="stat"/>
</bean>
<bean id="mallWriteSqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="mapperLocations" value="classpath:mall-mapper/**/write/**/*.xml" />
<!--<property name="typeAliasesPackage" value="com.ejavashop.entity" />-->
<property name="configLocation" value="classpath:mybatis-config.xml"></property>
<property name="dataSource" ref="mallWriteDataSource" />
</bean>
<bean name="shopMapperScannerWrite" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.sibu.orderHelper.mall.*.write" />
<property name="sqlSessionFactoryBeanName" value="mallWriteSqlSessionFactory" />
</bean>
<bean id="transactionManagerForMall" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="mallWriteDataSource"/>
</bean>
<tx:annotation-driven transaction-manager="transactionManagerForMall"/>
<!-- end 新系统mall -->
<!-- 配置事务的传播特性 -->
<!--<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>