Spring事物管理

<?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-2.5.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context-2.5.xsd
       http://www.springframework.org/schema/tx
       http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
       http://www.springframework.org/schema/aop
       http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"
default-lazy-init="false">


<context:component-scan base-package="com.demo" />


<!-- 定义数据源dataSource-->
<!-- 定义数据源Oracle -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property>
<property name="url" value="jdbc:oracle:thin:@10.85.128.126:1521/sanexcfg"></property>
<property name="username" value="sanex"></property>
<property name="password" value="sanex"></property>
<property name="initialSize" value="1"></property>
<property name="maxActive" value="500"></property>
<property name="maxIdle" value="5"></property>
<property name="minIdle" value="1"></property>
</bean>


<!-- 配置 ibatis 的sqlMapClient -->
<bean id="sqlMapClient"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation"
value="/WEB-INF/sqlMapConfig.xml" />
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="sqlMapClientOrac"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation"
value="/WEB-INF/sqlMapConfig.xml" />
<property name="dataSource" ref="dataSourceOracle" />
</bean>

<!-- 配置 多国语言 -->
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="message-info" />
<property name="useCodeAsDefaultMessage" value="true" />
</bean>

<!-- 获取datasrc -->
<!--  bean id="chrDataSourceWrap"
class="com.demo.vipkpi.data.CHRDataSourceWrap">
<property name="dataSource" ref="dataSource" />
</bean-->

<!-- ibatis 事务管理器 -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>

<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="modify*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="*" read-only="true" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="allManagerMethod"
expression="execution (* com.demo.*.*.*.*(..))" />
<aop:advisor advice-ref="txAdvice"
pointcut-ref="allManagerMethod" />
</aop:config>

<!-- Spring 提供的ibatis模版方法
<bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
<property name="sqlMapClient" ref="sqlMapClient" />
</bean>
-->
</beans>

你可能感兴趣的:(spring,oracle,bean,ibatis,配置管理)