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>
<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>
相关文章推荐
- Spring Batch Example – XML File To MongoDB Database(五)
- Spring Batch Example – MySQL Database To XML(七)
- 解决spring自动注解不能自动动态转换接口类成实现类的问题;一般在配置databaseSource的XML中如下配置
- 如何让spring开发中beans.xml出现属性提示
- springmvc.xml配置文件
- Spring中使用proxool的配置+【转】proxool.xml配置属性说明
- 【spring MVC学习一】web.xml中的spring的配置
- mybait整合spring 之xml
- (spring-第2回【IoC基础篇】)Spring的Schema,基于XML的配置
- spring注解和xml方式区别详解
- 【Spring in action】SpringMVC基于xml及java配置的简单运用
- 转:Spring XML配置十二个最佳实践
- Spring第八篇【XML、注解实现事务控制】
- spring applicationContext.xml 配置文件 详解
- spring和struts2的web.Xml配置(spring的web加载)
- [Spring]04_最小化Spring XML配置
- spring aop xml配置开发开发
- springmvc.xml和applicationContext.xml配置的特点
- Spring4Mvc纯注解启动,无web.xml
- spring的相关配置文件--web.xml