Configuration of spring.datasource.hikari.* properties in Finchley.M5 causes Spring Boot 2.0.0.RC1 application to fail
See original GitHub issueOriginally posted at https://github.com/spring-projects/spring-boot/issues/11901, but problem appears to lie with spring-cloud-commons, so re-posting here.
Hi,
I see this problem in 2.0.0.RC1 but not in 2.0.0.M7. My application contains several spring.datasource.hikari.* properties. (maximum-pool-size or schema are examples that cause this problem)
This causes the application to fail to start with the exception:
Caused by: java.lang.IllegalStateException: The configuration of the pool is sealed once started. Use HikariConfigMXBean for runtime changes.
It seems to be that the Datasource is configured on the initial refresh, and then again when this fires in ConfigurationPropertiesRebinder:
@Override
public void onApplicationEvent(EnvironmentChangeEvent event) {
rebind();
}
HikariCP V2.7.6 seals the configuration preventing properties from being changed. It seems the above application event tries to ‘reconfigure’ the sealed datasource and throws the above exception, causing the application to fail to start.
The newer HikariCP dependency is introduced via spring-boot-starter-jdbc 2.0.0.RC1. The 2.0.0.M7 version pulls in HikariCP 2.7.4 which (on first glance) doesn’t appear to seal the configuration in this way.
I can work around the issue for now by ensuring Hikari 2.7.4 appears first on the class path.
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (6 by maintainers)
Top Related StackOverflow Question
@dsyer hi,checkout https://github.com/ileler/java/tree/hikari-exception/hikari-exception view my code,
No problem at startup, the problem occurs when I refresh the configuration.
After startup, execute
curl -v -X POST localhost:11001/actuator/refreshon the command line.I tracked your code and found that adding the following configuration will handle this problem.
I have already dealt with the problem, but I still think this should be added to the default configuration, so I have a PR.
Mybatis is probably not something anyone tested. Please provide a link to a project that reproduces the problem.