org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.datasource.db1' to javax.sql.DataSource
只需要改动一个地方即可(每个数据源里的配置文件都需要改动)
原来代码:
@Bean(name ="db1DataSource")
@ConfigurationProperties(prefix ="spring.datasource.db1")
public DataSource getDateSource1(){return DataSourceBuilder.create().build();}
更改为:
@Bean(name ="data1SourceConfig")
@ConfigurationProperties(prefix ="spring.datasource.db1")
public HikariConfig hikariConfig(){return new HikariConfig();}
@Bean(name ="db1DataSource")
public DataSource dataSource(@Qualifier("data1SourceConfig") HikariConfig hikariConfig){return new HikariDataSource(hikariConfig);}