简体   繁体   中英

HikariCP not using settings from Spring Boot's application.properties

I am using Spring Boot 1.5.3 and I added the following settings for HikariCP in the application.properties :

spring.datasource.hikari.data-source-properties.prepStmtCacheSize=250
spring.datasource.hikari.data-source-properties.prepStmtCacheSqlLimit=2048
spring.datasource.hikari.data-source-properties.cachePrepStmts=true
spring.datasource.hikari.data-source-properties.useServerPrepStmts=true

spring.datasource.hikari.minimum-idle=7
spring.datasource.hikari.pool-name=Test-1

But once I start Spring Boot, the values of pool-name and minimum-idle are different :

[DEBUG]  HikariConfig - jdbcUrl........................."jdbc:mysql://localhost:3306/test?autoReconnect=true"
[DEBUG]  HikariConfig - leakDetectionThreshold..........0
[DEBUG]  HikariConfig - maxLifetime.....................1800000
[DEBUG]  HikariConfig - maximumPoolSize.................10
[DEBUG]  HikariConfig - metricRegistry..................none
[DEBUG]  HikariConfig - metricsTrackerFactory...........none
[DEBUG]  HikariConfig - minimumIdle.....................10
[DEBUG]  HikariConfig - password........................<masked>
[DEBUG]  HikariConfig - poolName........................"HikariPool-1"

Did you configure your Bean?:

@Configuration
public class HikariCPConfig {

@Bean
@ConfigurationProperties(prefix = "spring.datasource.hikari")
public HikariConfig hikariConfig() {
    return new HikariConfig();
}

@Bean
public DataSource dataSource() {
    return new HikariDataSource(hikariConfig());
}

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM