??????????????????????????
???????????? ???????[ 2016/1/21 14:46:28 ] ??????????????? ????????
???????????????????????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???????С????????????淶????????????????????????????????£???????????????????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11