Configuring Hikari Connection Pool with Spring Boot

In this article, we will learn the steps to configure Hikari with Spring Boot. We will cover steps to configure Hikari for both Spring Boot 1 and Spring Boot 2 application.



HikariCP is a reliable, high-performance JDBC connection pool. It is much faster, lightweight and have better performance as compare to other connection pool API. Because of all these compelling reasons, HikariCP is now the default pool implementation in Spring Boot 2. In this article, we will have a closer look to configure Hikari with Spring Boot.


1. Configuring Hikari with Spring Boot 1

Spring Boot 1 use the tomcat JDBC connection pool. Spring Boot automatically add dependency to tomcat-jdbc if you use the spring-boot-starter-jdbc or spring-boot-starter-data-jpastarters’ in your application. To configure Hikari  in our application, we have the following two options

  1. Add the HikariCP maven dependency.
  2. Remove the Tomcat JDBC connection pool and let Spring Boot look for HikariCP in the classpath.


1.1 Maven Dependency

The first step for Hikari and Spring Boot configuration is to add Hikari dependency in the pom.xml file:


[pullquote align=”normal”]Refer to HikariCP  for the latest release [/pullquote]


1.2 Remove Tomcat JDBC Dependency

Once we have the Hikari dependency in the class path, the next step is to remove the Tomcat JDBC dependency. This step will force Spring Boot to look for the Hikari data source in the class path. We can use the Maven standard <exclude> tag for this.

<!-- exclude tomcat jdbc connection pool, use HikariCP -->


2. Configuring Hikari with Spring Boot 2

Hikari is the default DataSource implementation with Spring Boot 2. This means we need not add explicit dependency in the pom.xml. The spring-boot-starter-jdbc and spring-boot-starter-data-jpa resolve it by default. To sum up, you require no other steps with Spring Boot 2.

[pullquote align=”normal”]For more details read. [/pullquote]


3. HikariCP Configurations

Let’s look at some important properties of the Hikari data source which can be useful for fine tuning our application.

spring.datasource.hikari.connection-timeout = 20000 #maximum number of milliseconds that a client will wait for a connection
spring.datasource.hikari.minimum-idle= 10 #minimum number of idle connections maintained by HikariCP in a connection pool
spring.datasource.hikari.maximum-pool-size= 10 #maximum pool size
spring.datasource.hikari.idle-timeout=10000 #maximum idle time for connection
spring.datasource.hikari.max-lifetime= 1000 # maximum lifetime in milliseconds of a connection in the pool after it is closed. =true #default auto-commit behavior.


4. Data Source Configuration

If you like to create a custom data source for your Spring Boot Hikari, we can create a simple configuration  class

public class DataSourceConfiguration {

    public DataSource customDataSource() {
        return DataSourceBuilder.create().build();


5. Hikari Log Output

Once we start our application, monitor the console log, you may notice an identical output:

2019-03-24 17:43:58.066  INFO 51692 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2019-03-24 17:43:58.072  WARN 51692 --- [  restartedMain] com.zaxxer.hikari.util.DriverDataSource  : Registered driver with driverClassName=com.mysql.jdbc.Driver was not found, trying direct instantiation.
2019-03-24 17:43:58.353  INFO 51692 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.



In this short article, we saw how to configure Hikari with Spring Boot. We also leaned that Hikari is the default data source in Spring Boot.

Oldest Most Voted
Inline Feedbacks
View all comments