2.1.1 版本中
datasource中 不再需要指定主数据源了
@Configuration @MapperScan(basePackages = "com.example.demo.mapper.test1", sqlSessionTemplateRef = "test1SqlSessionTemplate") public class DataSource1Config { @Bean(name = "test1DataSource") @ConfigurationProperties(prefix = "spring.datasource.test1") public DataSource testDataSource() { return DataSourceBuilder.create().build(); }
application.properties 设置 如下
#data01 spring.datasource.test1.url=jdbc:sqlserver://127.0.0.1:1433;databaseName=test01 spring.datasource.test1.username= spring.datasource.test1.passowrd= #data02 spring.datasource.test2.url=jdbc:sqlserver://127.0.0.1:1433;databaseName=test02 spring.datasource.test2.username= spring.datasource.test2.passowrd=