appProductContext.xml 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
  4. xmlns:aop="http://www.springframework.org/schema/aop"
  5. xmlns:context="http://www.springframework.org/schema/context"
  6. xsi:schemaLocation="
  7. http://www.springframework.org/schema/beans
  8. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd ">
  9. <bean id="dataSource"
  10. class="cn.sinobest.framework.comm.transcation.AppRoutingDataSource">
  11. <property name="targetDataSources">
  12. <map key-type="java.lang.String">
  13. <entry key="ds" value-ref="dataSource1" /> <!-- 数据源1 -->
  14. <entry key="ds2" value-ref="dataSource2" /><!-- 数据源2 -->
  15. </map>
  16. </property>
  17. <property name="defaultTargetDataSource" ref="dataSource1" /> <!-- 默认数据源为datasource1 -->
  18. </bean>
  19. <bean id="dataSource1" class="org.springframework.jndi.JndiObjectFactoryBean">
  20. <property name="jndiName"> <value>${jndi.name}</value> </property> <property
  21. name="resourceRef"> <value>true</value> </property> </bean>
  22. <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate" >
  23. <property name="dataSource" ref="dataSource" />
  24. </bean>
  25. <bean id="dataSource2" class="org.springframework.jndi.JndiObjectFactoryBean">
  26. <property name="jndiName">
  27. <value>${jndi.name2}</value>
  28. </property>
  29. <property name="resourceRef">
  30. <value>true</value>
  31. </property>
  32. </bean>
  33. </beans>