I want to use HikariCP as JDBC connection pool in my Spring boot application. I have two datasources (MySQL database as the primary database and accessing those data through Hib
Declaring your own DataSource
will already have implicity disabled Spring Boot's auto-configuration of a data source. In other words this won't be having any effect:
@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class})
I think the problem lies in the fact that you aren't binding Hikari-specific configuration to your MySQL DataSource
. You need to do something like this:
@Bean
@Primary
@ConfigurationProperties("spring.datasource.hikari")
public DataSource mySQLDataSource() {
return mySQLDataSourceProperties().initializeDataSourceBuilder().build();
}
This will mean that your mySQLDataSourceProperties
are configured with general-purpose data source configuration. They then create a HikariDataSource
which is further configured with the Hikari-specific configuration.