首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Spring事物治理

2012-09-21 
Spring事物管理?xml version1.0 encodingUTF-8?beans xmlnshttp://www.springframework.org/sc

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"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"
/>
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="sqlMapClientOrac"
/>
<property name="dataSource" ref="dataSourceOracle" />
</bean>

<!-- 配置 多国语言 -->
<bean id="messageSource"
value="message-info" />
<property name="useCodeAsDefaultMessage" value="true" />
</bean>

<!-- 获取datasrc -->
<!--  bean id="chrDataSourceWrap"
ref="dataSource" />
</bean-->

<!-- ibatis 事务管理器 -->
<bean id="transactionManager"
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" ref="sqlMapClient" />
</bean>
-->
</beans>

热点排行