spring全局事务配置和多数据源配置

spring全局事务配置和多数据源配置

<?xmlversion="1.0"encoding="UTF-8"?>

<!DOCTYPEbeansPUBLIC"-//SPRING//DTDBEAN//EN""http://www.springframework.org/dtd/spring-beans.dtd">

<beans>

<beanid="propertyConfigurer"

class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

<propertyname="locations">

<list>

<value>classpath*:com/kingdee/cfg/hibernate.properties</value>

</list>

</property>

</bean>

<beanid="dsA"class="org.apache.commons.dbcp.BasicDataSource"

destroy-method="close">

<propertyname="driverClassName"value="${jdbc.driverClassName}"/>

<propertyname="url"value="${jdbc.url}"/>

<propertyname="username"value="${jdbc.username}"/>

<propertyname="password"value="${jdbc.password}"/>

<propertyname="maxActive"value="50"/>

<propertyname="maxIdle"value="30"/>

<propertyname="maxWait"value="1000"/>

<propertyname="testWhileIdle"value="true"/>

<propertyname="timeBetweenEvictionRunsMillis"value="1800"/>

<propertyname="minEvictableIdleTimeMillis"value="1800"/>

</bean>

<beanid="dsB"class="org.apache.commons.dbcp.BasicDataSource"

destroy-method="close">

<propertyname="driverClassName"value="${jdbc1.driverClassName}"/>

<propertyname="url"value="${jdbc1.url}"/>

<propertyname="username"value="${jdbc1.username}"/>

<propertyname="password"value="${jdbc1.password}"/>

<propertyname="maxActive"value="50"/>

<propertyname="maxIdle"value="30"/>

<propertyname="maxWait"value="1000"/>

<propertyname="testWhileIdle"value="true"/>

<propertyname="timeBetweenEvictionRunsMillis"value="1800"/>

<propertyname="minEvictableIdleTimeMillis"value="1800"/>

</bean>

<beanid="sessionFactory"

class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

<propertyname="mappingLocations">

<value>classpath:mapping/sys/*.hbm.xml</value>

</property>

<propertyname="dataSource"ref="dsA"/>

<propertyname="hibernateProperties">

<props>

<propkey="hibernate.dialect">${hibernate.dialect}</prop>

<propkey="hibernate.show_sql">${hibernate.show_sql}</prop>

<propkey="hibernate.connection.release_mode">${hibernate.connection.release_mode}</prop>

</props>

</property>

</bean>

<beanid="sessionFactoryB"

class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

<propertyname="mappingLocations">

<value>classpath:mapping/sys/User.hbm.xml</value>

</property>

<propertyname="dataSource"ref="dsB"/>

<propertyname="hibernateProperties">

<props>

<propkey="hibernate.dialect">${hibernate1.dialect}</prop>

<propkey="hibernate.show_sql">${hibernate.show_sql}</prop>

<propkey="hibernate.connection.release_mode">${hibernate.connection.release_mode}</prop>

</props>

</property>

</bean>

<beanid="jotm"class="org.springframework.transaction.jta.JotmFactoryBean"/>

<beanid="txManager"

class="org.springframework.transaction.jta.JtaTransactionManager">

<propertyname="userTransaction"ref="jotm"/>

</bean>

<beanid="baseTransactionProxy"

class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"

abstract="true">

<propertyname="transactionManager"ref="txManager"/>

<propertyname="transactionAttributes">

<props>

<propkey="find*">PROPAGATION_REQUIRED,readOnly</prop>

<propkey="get*">PROPAGATION_REQUIRED,readOnly</prop>

<propkey="do*">PROPAGATION_REQUIRED,timeout_500,-Exception</prop>

</props>

</property>

</bean>

</beans>

相关推荐