时间:2021-07-01 10:21:17 帮助过:137人阅读
@Configuration public class DataSourceConfiguration { @Bean @Primary @ConfigurationProperties(prefix = "spring.datasource") public DataSource primaryDataSource() { return DataSourceBuilder.create().build(); } @Bean(name = "datasourceB") @ConfigurationProperties(prefix = "spring.second-datasource") public DataSource secondDataSource() { return DataSourceBuilder.create().build(); } }
@DimModule @Component public class TestModule implements SpringModule { @Autowired private DataSource dataSource = null; @Autowired @Qualifier("datasourceB ") private DataSource datasourceB = null; @Override public void loadModule(ApiBinder apiBinder) throws Throwable { apiBinder.installModule(new JdbcModule(Level.Full, this.dataSource)); //默认数据源 apiBinder.installModule(new JdbcModule(Level.Full, "datasourceB ", this.datasourceB )); // 数据源B} }
Spring Boot Dataway 配置多数据库源
标签:nbsp config private autowired new component auto jdb class