<?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: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/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">
<!-- 配置数据源 -->
<bean class="org.springframework.jdbc.datasource.DriverManagerDataSource" id="parentDataSource">
<property name="driverClassName"
value="com.mysql.jdbc.Driver">
</property>
<property name="username" value="yuoway"></property>
<property name="password" value="yuoway@store"></property>
</bean>
<!-- 数据库test -->
<bean parent="parentDataSource" id="adminDataSource">
<property name="url">
<value>jdbc:mysql://192.168.8.10:3306/report</value>
</property>
</bean>
<!-- 数据库test1 -->
<bean parent="parentDataSource" id="userDataSource">
<property name="url">
<value>jdbc:mysql://192.168.8.10:3306/customs</value>
</property>
</bean>
<!-- 编写spring 配置文件的配置多数源映射关系 -->
<bean class="com.probiz.estorepf.datasource.DynamicDataSource"
id="dataSource">
<property name="targetDataSources">
<map key-type="java.lang.String">
<entry value-ref="adminDataSource" key="12"></entry>
<entry value-ref="userDataSource" key="123"></entry>
</map>
</property>
<property name="defaultTargetDataSource"
ref="adminDataSource">
</property>
</bean>
<bean
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
id="sessionFactory">
<property name="dataSource">
<ref local="dataSource"></ref>
</property>
<!-- 实体映射资源 -->
<property name="mappingResources">
<list>
<value>com/probiz/estorepf/entity/AdminUsers.hbm.xml</value>
<value>com/probiz/estorepf/entity/Orders.hbm.xml</value>
<value>com/probiz/estorepf/entity/PaymentOrder.hbm.xml</value>
<value>com/probiz/estorepf/entity/OrderItem.hbm.xml</value>
<value>com/probiz/estorepf/entity/GeneralList.hbm.xml</value>
<value>com/probiz/estorepf/entity/PlatformArea.hbm.xml</value>
<value>com/probiz/estorepf/entity/BgEbilllist.hbm.xml</value>
<value>com/probiz/estorepf/entity/BgEcountrycode.hbm.xml</value>
<value>com/probiz/estorepf/entity/CurrencyCode.hbm.xml</value>
<value>com/probiz/estorepf/entity/MeasureMentUnit.hbm.xml</value>
<value>com/probiz/estorepf/entity/PackingCode.hbm.xml</value>
<value>com/probiz/estorepf/entity/TransportmodeCode.hbm.xml</value>
<value>com/probiz/estorepf/entity/AdminKey.hbm.xml</value>
<value>com/probiz/estorepf/entity/ReportGoods.hbm.xml</value>
<value>com/probiz/estorepf/entity/OrderLog.hbm.xml</value>
</list>
</property>
<!-- 为sessionFactory配置Hibernate属性 -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQL5Dialect
</prop>
<prop key="hibernate.show_sq">true</prop>
<prop key="hibernate.connection.autocommit">false</prop>
<prop key="hibernate.cache.use_query_cache">false</prop>
<prop key="hibernate.max_fetch_depth">2</prop>
<prop
key="hibernate.bytecode.use_reflection_optimizer">
true
</prop>
</props>
</property>
</bean>
<!-- 配置事务 -->
<bean id="txManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- 定义事务通知 -->
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="del*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="submit*" propagation="REQUIRED" />
<tx:method name="do*" propagation="REQUIRED" />
<tx:method name="get*" propagation="SUPPORTS" read-only="true" />
<tx:method name="find*" propagation="SUPPORTS" read-only="true" />
<tx:method name="search*" propagation="SUPPORTS" read-only="true" />
<tx:method name="query*" propagation="SUPPORTS" read-only="true" />
<tx:method name="*" rollback-for="REQUIRED" no-rollback-for="ClassCastException" />
</tx:attributes>
</tx:advice>
<!-- 定义哪些方法可以使用这些规则 -->
<aop:config>
<aop:pointcut id="serviceMethod" expression="execution(* com.probiz.estorepf.com.probiz.estorepf.action.*.*.*(..))" />
<!-- 将事务通知与应用规则的方法组合 -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethod" />
</aop:config>
<aop:config>
<aop:pointcut id="serviceMethodList" expression="execution(* com.probiz.estorepf.service.*.*.*(..))" />
<!-- 将事务通知与应用规则的方法组合 -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethodList" />
</aop:config>
<aop:config>
<aop:pointcut id="daoMethodList" expression="execution(* com.probiz.estorepf.dao.*.*(..))" />
<!-- 将事务通知与应用规则的方法组合 -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="daoMethodList" />
</aop:config>
<!-- 导入文件 -->
<!-- DAO -->
<import resource="applicationContext_dao.xml"/>
<!-- Service -->
<import resource="applicationContext_service.xml"/>
<!-- Action -->
<import resource="applicationContext_action.xml"/>
</beans>
<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: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/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">
<!-- 配置数据源 -->
<bean class="org.springframework.jdbc.datasource.DriverManagerDataSource" id="parentDataSource">
<property name="driverClassName"
value="com.mysql.jdbc.Driver">
</property>
<property name="username" value="yuoway"></property>
<property name="password" value="yuoway@store"></property>
</bean>
<!-- 数据库test -->
<bean parent="parentDataSource" id="adminDataSource">
<property name="url">
<value>jdbc:mysql://192.168.8.10:3306/report</value>
</property>
</bean>
<!-- 数据库test1 -->
<bean parent="parentDataSource" id="userDataSource">
<property name="url">
<value>jdbc:mysql://192.168.8.10:3306/customs</value>
</property>
</bean>
<!-- 编写spring 配置文件的配置多数源映射关系 -->
<bean class="com.probiz.estorepf.datasource.DynamicDataSource"
id="dataSource">
<property name="targetDataSources">
<map key-type="java.lang.String">
<entry value-ref="adminDataSource" key="12"></entry>
<entry value-ref="userDataSource" key="123"></entry>
</map>
</property>
<property name="defaultTargetDataSource"
ref="adminDataSource">
</property>
</bean>
<bean
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
id="sessionFactory">
<property name="dataSource">
<ref local="dataSource"></ref>
</property>
<!-- 实体映射资源 -->
<property name="mappingResources">
<list>
<value>com/probiz/estorepf/entity/AdminUsers.hbm.xml</value>
<value>com/probiz/estorepf/entity/Orders.hbm.xml</value>
<value>com/probiz/estorepf/entity/PaymentOrder.hbm.xml</value>
<value>com/probiz/estorepf/entity/OrderItem.hbm.xml</value>
<value>com/probiz/estorepf/entity/GeneralList.hbm.xml</value>
<value>com/probiz/estorepf/entity/PlatformArea.hbm.xml</value>
<value>com/probiz/estorepf/entity/BgEbilllist.hbm.xml</value>
<value>com/probiz/estorepf/entity/BgEcountrycode.hbm.xml</value>
<value>com/probiz/estorepf/entity/CurrencyCode.hbm.xml</value>
<value>com/probiz/estorepf/entity/MeasureMentUnit.hbm.xml</value>
<value>com/probiz/estorepf/entity/PackingCode.hbm.xml</value>
<value>com/probiz/estorepf/entity/TransportmodeCode.hbm.xml</value>
<value>com/probiz/estorepf/entity/AdminKey.hbm.xml</value>
<value>com/probiz/estorepf/entity/ReportGoods.hbm.xml</value>
<value>com/probiz/estorepf/entity/OrderLog.hbm.xml</value>
</list>
</property>
<!-- 为sessionFactory配置Hibernate属性 -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQL5Dialect
</prop>
<prop key="hibernate.show_sq">true</prop>
<prop key="hibernate.connection.autocommit">false</prop>
<prop key="hibernate.cache.use_query_cache">false</prop>
<prop key="hibernate.max_fetch_depth">2</prop>
<prop
key="hibernate.bytecode.use_reflection_optimizer">
true
</prop>
</props>
</property>
</bean>
<!-- 配置事务 -->
<bean id="txManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- 定义事务通知 -->
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="del*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="submit*" propagation="REQUIRED" />
<tx:method name="do*" propagation="REQUIRED" />
<tx:method name="get*" propagation="SUPPORTS" read-only="true" />
<tx:method name="find*" propagation="SUPPORTS" read-only="true" />
<tx:method name="search*" propagation="SUPPORTS" read-only="true" />
<tx:method name="query*" propagation="SUPPORTS" read-only="true" />
<tx:method name="*" rollback-for="REQUIRED" no-rollback-for="ClassCastException" />
</tx:attributes>
</tx:advice>
<!-- 定义哪些方法可以使用这些规则 -->
<aop:config>
<aop:pointcut id="serviceMethod" expression="execution(* com.probiz.estorepf.com.probiz.estorepf.action.*.*.*(..))" />
<!-- 将事务通知与应用规则的方法组合 -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethod" />
</aop:config>
<aop:config>
<aop:pointcut id="serviceMethodList" expression="execution(* com.probiz.estorepf.service.*.*.*(..))" />
<!-- 将事务通知与应用规则的方法组合 -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethodList" />
</aop:config>
<aop:config>
<aop:pointcut id="daoMethodList" expression="execution(* com.probiz.estorepf.dao.*.*(..))" />
<!-- 将事务通知与应用规则的方法组合 -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="daoMethodList" />
</aop:config>
<!-- 导入文件 -->
<!-- DAO -->
<import resource="applicationContext_dao.xml"/>
<!-- Service -->
<import resource="applicationContext_service.xml"/>
<!-- Action -->
<import resource="applicationContext_action.xml"/>
</beans>