__CONFIG_colors_palette__{"active_palette":0,"config":{"colors":{"40f3f":{"name":"Main Accent","parent":-1}},"gradients":[]},"palettes":[{"name":"Default","value":{"colors":{"40f3f":{"val":"var(--tcb-color-0)"}},"gradients":[]},"original":{"colors":{"40f3f":{"val":"rgb(127, 215, 132)","hsl":{"h":123,"s":0.52,"l":0.67,"a":1}}},"gradients":[]}}]}__CONFIG_colors_palette__

__CONFIG_colors_palette__{"active_palette":0,"config":{"colors":{"40f3f":{"name":"Main Accent","parent":-1}},"gradients":[]},"palettes":[{"name":"Default","value":{"colors":{"40f3f":{"val":"var(--tcb-color-0)"}},"gradients":[]},"original":{"colors":{"40f3f":{"val":"rgb(127, 215, 132)","hsl":{"h":123,"s":0.52,"l":0.67,"a":1}}},"gradients":[]}}]}__CONFIG_colors_palette__
Table of Contents

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.
spring.datasource.hikari.auto-commit =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.

5 1 vote
Article Rating

Related Posts

Java Development Journal

Hello!! Welcome to the Java Development Journal. We love to share our knowledge with our readers and love to build a thriving community.

Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Newest Most Voted
Inline Feedbacks
View all comments
{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
Would love your thoughts, please comment.x