springboot系列-多数据源
[TOC] 实现多数据源的配置。 配置数据源 @Configuration @MapperScan(basePackages = "com.example.moredatademo.mysqlmapper", sqlSessionTemplateRef = "mysqlSqlSessionTemplate") public class MysqlDataSourceConfig { @Bean(name = "mySqlDataSource") @ConfigurationProperties(prefix = "spring.datasource.mysqlone") @Primary public DataSource mySqlDataSource() { DataSource dataSource = DruidDataSourceBuilder.create().build(); return dataSource; } @Bean(name = "mysqlSqlSessionFactory") @Primary /*此处必须在主数据库的数据源配置上加上@