首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

spring2.5+atomikos分布式事宜配置

2012-09-21 
spring2.5+atomikos分布式事务配置首先为src目录下的app_jta.xml(数据源及事务配置):?xml version1.0

spring2.5+atomikos分布式事务配置
首先为src目录下的app_jta.xml(数据源及事务配置):

<?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"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/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"><aop:config proxy-target-expression="execution(* com.service.impl.*.*(..))" /><aop:advisor pointcut-ref="serviceOperation" advice-ref="txAdvice" /></aop:config><tx:advice id="txAdvice" transaction-manager="transactionManager"><tx:attributes><tx:method name="del*" propagation="REQUIRED" rollback-for="Throwable"/><tx:method name="save*" propagation="REQUIRED" rollback-for="Throwable"/><tx:method name="update*" propagation="REQUIRED" rollback-for="Throwable"/><tx:method name="add*" propagation="REQUIRED" rollback-for="Throwable"/><tx:method name="create*" propagation="REQUIRED" rollback-for="Throwable"/><tx:method name="get*" read-only="true" /><tx:method name="query*" read-only="true" /><tx:method name="*" /></tx:attributes></tx:advice><bean id="propertyConfigurer"destroy-method="close"><property name="uniqueResourceName" value="${mysqlA.uniqueResourceName}" /><property name="xaDataSourceClassName" value="${mysql.xaDataSourceClassName}" /><property name="xaProperties"><props><prop key="user">${mysql.user}</prop><prop key="password">${mysql.password}</prop><prop key="URL">${mysqlA.url}</prop></props></property><property name="poolSize" value="${mysql.poolSize}" /></bean><bean id="dataSourceB" destroy-method="close"><property name="uniqueResourceName" value="${mysqlB.uniqueResourceName}" /><property name="xaDataSourceClassName" value="${mysql.xaDataSourceClassName}" /><property name="xaProperties"><props><prop key="user">${mysql.user}</prop><prop key="password">${mysql.password}</prop><prop key="URL">${mysqlB.url}</prop></props></property><property name="poolSize" value="${mysql.poolSize}" /></bean><bean id="atomikosTransactionManager" destroy-method="close"><property name="forceShutdown" value="${transactionManager.forceShutdown}" /></bean><bean id="atomikosUserTransaction" value="${transactionManager.transactionTimeout}" /></bean><bean id="transactionManager"/></property><property name="userTransaction"><ref bean="atomikosUserTransaction" /></property></bean><!--<tx:annotation-driven transaction-manager="transactionManager"proxy-target-/>--><!-- dao --><bean id="userDaoA" ref="dataSourceA" /></bean><bean id="userDaoB" ref="dataSourceB" /></bean><bean id="userService" ref="userDaoA" /><property name="userDaoB" ref="userDaoB" /></bean><bean id="userCtl" ref="userService" /></bean></beans>


接下来为WEB-INF下的spring-servlet.xml(SPRING MVC配置):

<?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"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/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"><!-- 方法名解析器 --><bean id="InternalPathMethodNameResolver"/><!--  对模型视图名称的解析,在请求时模型视图名称添加前后缀  --><beanp:suffix=".jsp" /><bean id="urlMapping"/>  

热点排行