Java 常用注解@Configuration,@Bean及@ConfigurationProperties(prefix = "spring.datasource")
@Configuration public class EventDataSourceConfig { @Bean(name = "eventdataSource") @ConfigurationProperties(prefix="datasource.event") public DataSource oldDataSource() { return DataSourceBuilder.create().build(); } @Bean(name = "eventjdbcTemplate") public JdbcTemplate oldjdbcTemplate(@Qualifier("eventdataSource") DataSource dataSource) { return new JdbcTemplate(dataSource); } }
datasource:
event: