Reputation: 1315
I'm configuring HikariCP for Spring Boot application, the database is Postgresql.
The documentation says:
"We recommended using dataSourceClassName
instead of jdbcUrl
, but either is acceptable."
However, the next line says:
"Note: Spring Boot auto-configuration users, you need to use jdbcUrl
-based configuration."
If we use jdbcUrl
-based configuration and specify dataSourceClassName
then jdbcUrl
will be ignored, if we don't specify data source - HikariDataSource
will be created. So they recommend using HikariDataSource
for Spring Boot apps.
If we use dataSourceClassName
- it will be created with given properties (in my case it is PGSimpleDataSource
with its ancestor BaseDataSource
).
Both these configurations work for me.
So, my questions are:
HikariDataSource
and PGSimpleDataSource
(or any other recommended)? jdbcUrl
-based configuration (and thus HikariDataSource
) in Spring Boot?Upvotes: 3
Views: 7818
Reputation: 4620
HikariCP is a connection pool, and a very good one. We've been using it in several projects in production and it's fast and just works.
If you want to use HikariCP you use HikariDataSource
. Spring Boot has started to use it as a default and recommends it (for the same reasons: it's fast and solid).
If you just use the default configuration with spring.datasource.url
, it will use HikariCP and should work out-of-the-box.
However, when you manually configure your datasource(s), there is a small issue with Spring Boot 2 and HikariCP. HikariCP expects jdbcUrl
or dataSourceClassName
, but the Spring Boot configuration property uses url
.
See the documentation or this question for that.
Upvotes: 5