Partner – Moderne – NPI EA (cat=Spring Boot)
announcement - icon

Refactor Java code safely — and automatically — with OpenRewrite.

Refactoring big codebases by hand is slow, risky, and easy to put off. That’s where OpenRewrite comes in. The open-source framework for large-scale, automated code transformations helps teams modernize safely and consistently.

Each month, the creators and maintainers of OpenRewrite at Moderne run live, hands-on training sessions — one for newcomers and one for experienced users. You’ll see how recipes work, how to apply them across projects, and how to modernize code with confidence.

Join the next session, bring your questions, and learn how to automate the kind of work that usually eats your sprint time.

Course – Black Friday 2026 – NPI EA – main – before_post_content
announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

Course – Black Friday 2026 – NPI – main – before_post_content
announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

1. Overview

Hikari is a JDBC DataSource implementation that provides a connection pooling mechanism. Compared to other implementations, it promises to be lightweight and better performing.

This quick tutorial shows how to configure a Spring Boot 3 application to use the Hikari DataSource.

2. Configuring Hikari With Spring Boot 3.x

Hikari is the default DataSource implementation in Spring Boot 3, as stated in the reference manual.

The dependency on Hikari is automatically included in spring-boot-starter-data-jpa and spring-boot-starter-jdbc. Hence, there’s nothing we need to do if we want to use Hikari in an application based on Spring Boot 3.x.

However, if we want to use the latest version, we need to add the Hikari dependency in the pom.xml explicitly:

<dependency>
    <groupId>com.zaxxer</groupId>
    <artifactId>HikariCP</artifactId>
    <version>7.0.2</version>
</dependency>

3. Tuning Hikari Configuration Parameters

One of Hikari’s advantages over other DataSource implementations is that it offers a lot of configuration parameters.

We can specify the values for these parameters by using the prefix spring.datasource.hikari and appending the name of the Hikari parameter:

spring.datasource.hikari.connectionTimeout=30000 
spring.datasource.hikari.idleTimeout=600000 
spring.datasource.hikari.maxLifetime=1800000 
...

In the above configuration, we’ve set the connection timeout to 30,000 milliseconds, idle timeout to 600,000 milliseconds, and maximum lifetime to 1,800,000 milliseconds. These parameter values can be adjusted based on the specific requirements of our application.

A comprehensive list of all available Hikari parameters with detailed explanations is available on the Hikari GitHub site, as well as in the Spring docs.

4. Monitoring Hikari With JMX

Hikari provides support for monitoring its connection pool through JMX (Java Management Extensions). JMX is a Java technology that enables the management and monitoring of applications at runtime. By enabling JMX for Hikari, we can gain valuable insights into the health and performance of our connection pool.

To enable JMX for Hikari, we need to add the following configuration property to our application.properties or application.yml file:

spring.datasource.hikari.registerMbeans=true

With this configuration in place, Hikari exposes its management beans through JMX. These beans can be accessed using JMX tools and libraries to monitor and analyze the connection pool. There are several popular JMX clients available, such as JConsole, VisualVM, and Prometheus with JMX exporter.

By connecting to the Java process hosting the application and using a JMX client, we can access various metrics and attributes provided by Hikari. Some of the key metrics include:

  • Connection count: current number of active connections
  • Pool utilization: percentage of connections in use
  • Connection acquisition time: time taken to acquire a connection from the pool
  • Connection creation time: time taken to create a new connection
  • Connection timeout count: number of connection acquisition attempts that timed out

These metrics can help us understand the behavior of our connection pool and identify any potential performance bottlenecks or issues. We can set up monitoring and alerting systems to track these metrics and take appropriate actions when necessary.

5. Conclusion

In this article, we saw how to configure the Hikari DataSource for a Spring Boot 3.x application, taking advantage of Spring Boot’s autoconfiguration capabilities. Furthermore, we highlighted the significance of enabling Hikari JMX to monitor and manage the connection pool, providing us with valuable insights and control over its behavior.

The code backing this article is available on GitHub. Once you're logged in as a Baeldung Pro Member, start learning and coding on the project.
Partner – Moderne – NPI EA (tag=Refactoring)
announcement - icon

Modern Java teams move fast — but codebases don’t always keep up. Frameworks change, dependencies drift, and tech debt builds until it starts to drag on delivery. OpenRewrite was built to fix that: an open-source refactoring engine that automates repetitive code changes while keeping developer intent intact.

The monthly training series, led by the creators and maintainers of OpenRewrite at Moderne, walks through real-world migrations and modernization patterns. Whether you’re new to recipes or ready to write your own, you’ll learn practical ways to refactor safely and at scale.

If you’ve ever wished refactoring felt as natural — and as fast — as writing code, this is a good place to start.

Course – Black Friday 2026 – NPI EA – main – after_post_content

announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

Course – Black Friday 2026 – NPI – main – after_post_content

announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW