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:

 

posted @ 2023-07-03 15:53  八英里  阅读(37)  评论(0编辑  收藏  举报