HikariDataSource cannot be initialized at application startup
See original GitHub issueSpring Boor version: 2.2.2.RELEASE
HikariCP version: 3.4.1
Now, I only initialize the database connection when the application is accessed. If the database connection has errors, I can’t find the problem quickly. I tried some methods and still can’t solve it. E.g
@Bean
public LazyInitializationExcludeFilter excludeFilter() {
return LazyInitializationExcludeFilter.forBeanTypes(HikariDataSource.class);
}
E.g
spring:
main:
lazy-initialization: false
I have two apps with this problem now. One of them runs on JDK8 and the other runs on JDK13.
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (5 by maintainers)
Top Results From Across the Web
How to configure hikari pool for eager initialization?
I want to configure the Hikari pool to eagerly initialize on application startup and not when first query is issued.
Read more >Stack trace switching over to Hikari Datasource - Google Groups
Had success converting an application using HikariConfig and another user Hikari Datasource within Tomcat but the next app on my list is failing...
Read more >DriverManagerDataSource (Spring Framework 6.0.2 API)
This driver will get initialized on startup, registering itself with the JDK's DriverManager. NOTE: DriverManagerDataSource is primarily intended for accessing ...
Read more >Introduction to HikariCP - Baeldung
HikariConfig is the configuration class used to initialize a data source. It comes with four well-known, must-use parameters: username, password ...
Read more >Connection Pool Configuration in Spring Boot. | by Thanh Tran
And now we have both common-dbcp and HikariCP on the application classpath, ... therefore I cannot mention all of it in this post...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for the update, I am with you now. I got a little bit confused as I thought this was happening by default as well.
Let’s take a step back. This problem has nothing to do with lazy initialization. As I’ve indicated above, this feature is disabled by default. What’s happening is that the connection pool for the
DataSource(Hikari) is created but nothing is requiring aConnection. The connection pool does not attempt to reach the database until a connection is requested.Adding the following bean is enough to force validation on startup:
It looks like your other projects are not affected and the Hikari pool is starting when the application starts. Can you check the differences with the samples you’ve attached?
Also flagging for team attention as I don’t know what the next steps for this one should be.
@snicoll Thank you for the example.
I added this code. When this code is run, a connection pool is created. It’s really fun.