copy from safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/MyBatisConfigOne.java
copy to safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/MyBatisConfigGoalManage.java
文件从 safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/MyBatisConfigOne.java 复制 |
| | |
| | | import java.util.Arrays; |
| | | |
| | | @Configuration |
| | | @MapperScan(basePackages = {"com.gkhy.safePlatform.emergency","com.gkhy.safePlatform.goalManage"}, |
| | | sqlSessionTemplateRef = "sqlTemplate1",annotationClass = |
| | | @MapperScan(basePackages = {"com.gkhy.safePlatform.goalManage"}, |
| | | sqlSessionTemplateRef = "sqlTemplateGoalManage",annotationClass = |
| | | Repository.class) |
| | | public class MyBatisConfigOne { |
| | | public class MyBatisConfigGoalManage { |
| | | |
| | | @Autowired |
| | | @Qualifier("dsOne") |
| | | DataSource dsOne; |
| | | @Qualifier("dsGoalManage") |
| | | DataSource dsGoalManage; |
| | | |
| | | @Autowired |
| | | private MybatisPlusInterceptor mybatisPlusInterceptor; |
| | | |
| | | @Bean(name = "datasource1") |
| | | @ConfigurationProperties(prefix = "spring.datasource.one") |
| | | public DruidDataSource druidDataSourceA(){ |
| | | @Bean(name = "dataSourceGoalManage") |
| | | @ConfigurationProperties(prefix = "spring.datasource.goalmanage") |
| | | public DruidDataSource dataSourceGoalManage(){ |
| | | return DruidDataSourceBuilder.create().build(); |
| | | } |
| | | |
| | | @Bean(name = "sqlFactory1") |
| | | public SqlSessionFactory sqlSessionFactory(@Qualifier("datasource1") DruidDataSource dataSource) |
| | | @Bean(name = "sqlFactoryGoalManage") |
| | | public SqlSessionFactory sqlSessionFactory(@Qualifier("dataSourceGoalManage") DruidDataSource dataSource) |
| | | throws Exception |
| | | { |
| | | MybatisSqlSessionFactoryBean factoryBean = new MybatisSqlSessionFactoryBean(); |
| | |
| | | ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); |
| | | |
| | | //------------------- |
| | | Resource[] rs1 = resolver.getResources("classpath*:config/mapper/emergency/**Mapper.xml"); |
| | | Resource[] rs2 = resolver.getResources("classpath*:config/mapper/goalManage/**Mapper.xml"); |
| | | Resource[] rs1 = resolver.getResources("classpath*:config/mapper/goalManage/**Mapper.xml"); |
| | | // Resource[] rs2 = resolver.getResources("classpath*:config/mapper/goalManage/**Mapper.xml"); |
| | | ArrayList<Resource> resourceArrayList = new ArrayList<>(Arrays.asList(rs1)); |
| | | resourceArrayList.addAll(new ArrayList<>(Arrays.asList(rs2))); |
| | | // resourceArrayList.addAll(new ArrayList<>(Arrays.asList(rs2))); |
| | | Resource[] resourceArray = new Resource[resourceArrayList.size()]; |
| | | resourceArrayList.toArray(resourceArray); |
| | | factoryBean.setMapperLocations(resourceArray); |
| | |
| | | return factoryBean.getObject(); |
| | | } |
| | | |
| | | @Bean(name = "sqlTemplate1") |
| | | public SqlSessionTemplate sqlSessionTemplate(@Qualifier("sqlFactory1") SqlSessionFactory sqlSessionFactory) |
| | | @Bean(name = "sqlTemplateGoalManage") |
| | | public SqlSessionTemplate sqlSessionTemplate(@Qualifier("sqlFactoryGoalManage") SqlSessionFactory sqlSessionFactory) |
| | | { |
| | | return new SqlSessionTemplate(sqlSessionFactory); |
| | | } |