As a suggestion, in case you want to use a connection pool other than Hikari it would be nice to be able to perform the Hikari exclusion with the property "spring.datasource.hikari.enabled = false", without having to do it in the following way :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<exclusions>
<exclusion>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
</exclusion>
</exclusions>
</dependency>
Also, this is a problem if you want to exclude the Hikari dependency from dependencyManagement since the forces hardcode the spring-boot version:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<version>2.1.5.RELEASE</version>
<exclusions>
<exclusion>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
With the property spring.datasource.hikari.enabled you can evaluate the load of autoconfigurations that now continue to be loaded only by evaluating the simple presence of the class in the classpath:
DataSourceJmxConfiguration.Hikari matched:
- @ConditionalOnClass found required class 'com.zaxxer.hikari.HikariDataSource' (OnClassCondition)
DataSourcePoolMetadataProvidersConfiguration.HikariPoolDataSourceMetadataProviderConfiguration matched:
- @ConditionalOnClass found required class 'com.zaxxer.hikari.HikariDataSource' (OnClassCondition)
DataSourceConfiguration.Hikari:
Did not match:
- @ConditionalOnProperty (spring.datasource.type=com.zaxxer.hikari.HikariDataSource) found different value in property 'spring.datasource.type' (OnPropertyCondition)
Matched:
- @ConditionalOnClass found required class 'com.zaxxer.hikari.HikariDataSource' (OnClassCondition)
DataSourcePoolMetadataProvidersConfiguration.HikariPoolDataSourceMetadataProviderConfiguration matched:
- @ConditionalOnClass found required class 'com.zaxxer.hikari.HikariDataSource' (OnClassCondition)
It's just a suggestion. thank you
I think this "enabled" property would be useful because HikariCP is a "special" case as it is included by default as a "compile" dependency in spring-boot-starter-jdbc.
Other connection pool libraries like tomcat-pool or dbcp2 are not included so their "enabled" properties are not useful, you can just not include their dependency..
@juliojgd Spring Boot already offers a spring.datasource.type property where you can specify the connection pool to use. If you're not happy excluding the dependency then you should give that a try. We don't offer enabled property for core features.
Most helpful comment
I think this "enabled" property would be useful because HikariCP is a "special" case as it is included by default as a "compile" dependency in
spring-boot-starter-jdbc.Other connection pool libraries like
tomcat-poolordbcp2are not included so their "enabled" properties are not useful, you can just not include their dependency..