๐ด The Error You're Seeing
Confirm this matches your console output. If it does, you're in the right place.
2026-02-20 14:22:18.300 ERROR 8842 --- [ main] o.s.boot.SpringApplication : Application run failed
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: java.lang.IllegalStateException: No DataSource class found for type: com.zaxxer.hikari.HikariDataSource
Caused by: java.lang.ClassNotFoundException: com.zaxxer.hikari.HikariDataSourceโก Quick Fix Works 80% of the time
Add spring-boot-starter-jdbc or spring-boot-starter-data-jpa to your pom.xml.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>๐ง Why this Happens
Tap to expand the deep technical explanation
Spring Boot defaults to using HikariCP for database connection pooling. When it tried to configure the DataSource, the JVM tried to load the `HikariDataSource` class, but couldn't find it. This means `HikariCP.jar` is missing from your classpath, or it was accidentally excluded.
The HITEC City Parking Spot Analogy:
It's like trying to drive a car, but the engine (HikariCP) was never installed at the factory. You have the keys and the steering wheel, but no power to move.
๐ How to Reproduce Confirm this is your error
Create a Spring Boot app. Add a `spring.datasource.url` to properties. Do NOT add `spring-boot-starter-jdbc` or `spring-boot-starter-data-jpa`. Run the app.
๐ ๏ธ Solutions (5 Ways to Fix)
Add the JDBC starter dependency
๐ Use this if you are doing manual JDBC or Spring Data JPA.
The `spring-boot-starter-jdbc` and `spring-boot-starter-data-jpa` starters automatically include HikariCP.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>Manually add HikariCP dependency
๐ Use this if you only want the pool without the full Spring Data JPA overhead.
Explicitly add the Hikari jar to your pom.xml.
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>5.1.0</version>
</dependency>Fix Maven Shade / Fat Jar exclusions
๐ Use this if the dependency is in your pom.xml, but missing at runtime.
If you are building a custom fat-jar, your `maven-shade-plugin` might be excluding HikariCP. Ensure it is included in the final artifact.
<!-- Check shade plugin config for unwanted exclusions -->Switch to a different connection pool
๐ Use this if you absolutely must use Tomcat JDBC pool.
Tell Spring Boot to stop looking for Hikari and use Tomcat's pool instead.
# application.properties
spring.datasource.type=org.apache.tomcat.jdbc.pool.DataSourceExclude DataSource Auto-Configuration
๐ Use this if you are not using a database at all.
If the error is happening because a property triggered auto-config but you don't need a DB, turn it off.
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})๐ Version Notes
HikariCP is the default pool.
HikariCP is the default pool.
๐ก๏ธ How to Prevent This Next Time
Always use Spring Initializr to generate your project. Checking the 'Spring Data JPA' or 'JDBC API' boxes guarantees the correct pooling dependencies are added.