???????????????????????spring?????????spring-datasource-dbunit.xml

<?xml version="1.0" encoding="UTF-8"?>
<beansxmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"
default-autowire="byName">
<description>spring-datasource-configuration</description>
<beanclass="com.angel.context.ApplicationContextAwareHelper"/>
<!-- ?????????????????????????? -->
<beanid="transactionManager"class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<propertyname="dataSource"ref="dataSource"/>
</bean>
<tx:annotation-driventransaction-manager="transactionManager"/>
<beanid="propertyConfigurer"class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer">
<propertyname="locations">
<list>
<value>classpath*:props/datasource_dev.properties</value>
</list>
</property>
</bean>
<beanid="dataSource"class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<propertyname="driverClassName"value="${jdbc.driver}"/>
<propertyname="url"
value="${jdbc.dbunit.url}"/>
<propertyname="username"value="${jdbc.user}"/>
<propertyname="password"value="${jdbc.password}"/>
</bean>
<!-- MyBatis ???? -->
<beanclass="org.mybatis.spring.mapper.MapperScannerConfigurer">
<propertyname="basePackage"value="com.angel.*.dao"/>
<propertyname="sqlSessionFactoryBeanName"value="xSqlSessionFactory"/>
</bean>
<beanid="xSqlSessionFactory"class="org.mybatis.spring.SqlSessionFactoryBean">
<propertyname="dataSource"ref="dataSource"/>
<propertyname="typeAliasesPackage"value="com.angel.*.entities"/>
<propertyname="configLocation"value="classpath:mybatis/mybatis-config.xml"/>
<propertyname="mapperLocations"value="classpath:/com/angel/dao/*.xml"/>
<propertyname="plugins">
<array>
<!--page interceptor-->
<beanclass="com.angel.orm.db.QueryInterceptor"/>
</array>
</property>
</bean>
<tx:annotation-driventransaction-manager="transactionManager"/>
</beans>

?????????????????????????????????????κε????????????????????????????????????Insert????????????????????в???в????κ????????????????????????У???Insert??get??????????????????????
?????????????ApplicationContextAwareHelper.class

????publicclassApplicationContextAwareHelperimplementsApplicationContextAware{
????privatestaticApplicationContext context;
????@Override
????publicvoid setApplicationContext(ApplicationContext applicationContext){
????context = applicationContext;
????}
????publicstaticApplicationContext getContext(){
????return context;
????}
????}

???????????????????????Щbean??????ApplicationContextAwareHelper?????????????????????bean??????????????bean?????????????????????????
????DruidDataSource dataSource =ApplicationContextAwareHelper.getBean("dataSource_"+ dataSources[i]);
?????????????????????????????е????????????????????????????
?????塢???????????
??????????????????????????????????
?????????????????????????????з????????????????????????????????????????У?????С??????????У?????????????????????????????????????????????С??????????С?????????????????淶??????С??淶????????????????????????????????????????????????????????????????????????????????????β????鷳?????????????????????????????????????????????????t???????С????????????淶????????????????????????????????£???????????????????????????????????