您的位置:首页 > 编程语言 > Java开发

spring-database_stats.xml

2016-01-14 16:04 323 查看
<?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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
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/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">

<!-- 数据源配置,使用应用内的DBCP数据库连接池 -->
<!-- mysql数据源配置,使用应用内的DBCP数据库连接池 -->
<bean id="dataSource_stats_db" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>${jdbc.mysql.driverClassName}</value>
</property>
<property name="url">
<value>${jdbc.stats_db.url}</value>
</property>
<property name="username">
<value>${jdbc.stats_db.mysql.username}</value>
</property>
<property name="password">
<value>${jdbc.stats_db.mysql.password}</value>
</property>
<property name="maxActive">
<value>${jdbc.mysql.maxActive}</value>
</property>
<property name="maxWait">
<value>${jdbc.mysql.maxWait}</value>
</property>
<property name="maxIdle">
<value>${jdbc.mysql.maxIdle}</value>
</property>
<property name="initialSize">
<value>${jdbc.mysql.initSize}</value>
</property>
<property name="removeAbandoned">
<value>true</value>
</property>
<property name="defaultAutoCommit">
<value>true</value>
</property>
<property name="defaultReadOnly">
<value>false</value>
</property>
<property name="testOnBorrow">
<value>true</value>
</property>
<property name="validationQuery">
<value>select 1</value>
</property>
</bean>

<bean id="sqlSessionFactory_stats_db" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource_stats_db" />
<property name="configLocation" value="classpath:mysqlmap-config.xml" />
<property name="mapperLocations">
<value>classpath*:com/pingan/haofang/mysql/*.xml</value>
</property>
</bean>


<bean id="sqlSession_stats_db" class="org.mybatis.spring.SqlSessionTemplate" scope="prototype">
<constructor-arg index="0" ref="sqlSessionFactory_stats_db" />
</bean>

<!-- 添加Spring的JDBC操作的Template Bean -->
<bean id="jdbcTemplate_stats_db" class="org.springframework.jdbc.core.JdbcTemplate" >
<property name="dataSource">
<ref bean="dataSource_stats_db" />
</property>
</bean>


<!-- 连接事务的注解配置 <tx:annotation-driven transaction-manager="transactionManager"/> -->

<!-- Transaction manager for a single JDBC DataSource -->

<bean id="transactionManager_stats_db"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource_stats_db" />
</bean>
<tx:advice id="txAdvice_stats_db" transaction-manager="transactionManager_stats_db">
<tx:attributes>
<tx:method name="insert*" propagation="REQUIRED" />
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="*" propagation="REQUIRED" read-only="true" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="allManagerMethod_stats_db"
expression="execution(* com.pingan.haofang..*.*service.impl.*(..))" />
<aop:advisor advice-ref="txAdvice_stats_db" pointcut-ref="allManagerMethod_stats_db" />
</aop:config>

</beans>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: