1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
| // 主数据源 @Configuration @MapperScan(basePackages = "com.lo.multipools.mapper.bpm", sqlSessionTemplateRef = "bpmSqlSessionTemplate") public class DataSourceBpm { @Primary @Bean("bpmDataSourceProperties") @ConfigurationProperties(prefix = "spring.datasource.bpm") public DataSourceProperties bpmDataSourceProperties() { return new DataSourceProperties(); }
@Primary @Bean(name = "bpmDataSource") public DataSource bpmDataSource(@Qualifier("bpmDataSourceProperties") DataSourceProperties dataSourceProperties) { return dataSourceProperties.initializeDataSourceBuilder().build(); }
@Primary @Bean("bpmSqlSessionFactory") public SqlSessionFactory bpmSqlSessionFactory(@Qualifier("bpmDataSource") DataSource dataSource) throws Exception { SqlSessionFactoryBean sqlSessionFactory = new SqlSessionFactoryBean(); sqlSessionFactory.setDataSource(dataSource); sqlSessionFactory.setMapperLocations( // 配置mapper.xml路劲 new PathMatchingResourcePatternResolver().getResources("classpath*:/mybatis/bpm/**/*.xml")); return sqlSessionFactory.getObject(); }
@Primary @Bean(name = "bpmTransactionManager") public DataSourceTransactionManager bpmTransactionManager(@Qualifier("bpmDataSource") DataSource dataSource) { return new DataSourceTransactionManager(dataSource); }
@Primary @Bean(name = "bpmSqlSessionTemplate") public SqlSessionTemplate bpmSqlSessionTemplate( @Qualifier("bpmSqlSessionFactory") SqlSessionFactory sqlSessionFactory) { return new SqlSessionTemplate(sqlSessionFactory); } }
// dudao数据源 @Configuration @MapperScan(basePackages = "com.lo.multipools.mapper.dudao", sqlSessionTemplateRef = "dudaoSqlSessionTemplate") public class DataSourceDudao { @Bean(name = "dudaoDataSourceProperties") @ConfigurationProperties(prefix = "spring.datasource.dudao") public DataSourceProperties dudaoDataSourceProperties() { return new DataSourceProperties(); }
@Bean(name = "dudaoDataSource") public DataSource dudaoDataSource( @Qualifier("dudaoDataSourceProperties") DataSourceProperties dataSourceProperties) { return dataSourceProperties.initializeDataSourceBuilder().build(); }
@Bean("dudaoSqlSessionFactory") public SqlSessionFactory bpmSqlSessionFactory(@Qualifier("dudaoDataSource") DataSource dataSource) throws Exception { SqlSessionFactoryBean sqlSessionFactory = new SqlSessionFactoryBean(); sqlSessionFactory.setDataSource(dataSource); sqlSessionFactory.setMapperLocations( // 配置mapper.xml路劲 new PathMatchingResourcePatternResolver().getResources("classpath*:/mybatis/dudao/**/*.xml")); return sqlSessionFactory.getObject(); }
@Bean(name = "dudaoTransactionManager") public DataSourceTransactionManager bpmTransactionManager(@Qualifier("dudaoDataSource") DataSource dataSource) { return new DataSourceTransactionManager(dataSource); }
@Bean(name = "dudaoSqlSessionTemplate") public SqlSessionTemplate bpmSqlSessionTemplate( @Qualifier("dudaoSqlSessionFactory") SqlSessionFactory sqlSessionFactory) { return new SqlSessionTemplate(sqlSessionFactory); } }
|