I want to have multiple DataSource in my application. Therefore cannot rely on the datasource autoconfiguration of Spring and have to create my own, like this:
@Bean
@Primary
@ConfigurationProperties("spring.datasource.custom")
public DataSource primaryDataSource() {
return DataSourceBuilder.create().build();
}
spring.datasource.custom.url=jdbc:mysql://localhost/tablename
spring.datasource.custom.username=root
spring.datasource.custom.password=rootpw
spring.datasource.custom.driver-class-name=com.mysql.jdbc.Driver
#the important part:
spring.datasource.custom.tomcat.test-on-borrow=true
spring.datasource.custom.tomcat.validation-query=SELECT 1
Problem: the .tomcat.* properties are not automatically picked up.
Question: how can I get them into the DataSource?