Spring Boot fails at startup with an error processing a condition on an auto-configuration
java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.jdbc.JndiDataSourceAutoConfigurationShort answer
This message only says Spring Boot failed while evaluating an auto-configuration condition. The real reason is in the Caused by lines below it. In Gradle projects it is often a Java or Gradle version the Spring Boot release does not support, or hand-picked Spring library versions that do not match the Boot BOM.
Fix it fast
1Find out which cause you have
Do not stop at the first line. Print the whole stack trace and read the last Caused by line, which names the class or version that fails. Start the app with the debug switch to get the conditions report.
./gradlew bootRun --stacktrace java -jar build/libs/my-app.jar --debug2Match what you see, then jump to its fix
- 1
The last Caused by line names a class that fails to load, and your Java or Gradle is outside the support tableThe Java or Gradle version is not supported by this Spring Boot releaseFix - 2
The build file pins versions of Spring or other managed libraries by handSpring library versions do not match the Spring Boot BOMFix - 3
The app uses a JNDI name, or no spring.datasource.url at allA data source is configured, but not in the way the app expectsFix
- 1
What does the error look like?
java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.jdbc.JndiDataSourceAutoConfiguration
Cause 1 of 3
The Java or Gradle version is not supported by this Spring Boot release
1Check
Each Spring Boot version lists the Java and Gradle versions it supports. Current releases need Java 17 or later and Gradle 8.14 or later (8.x) or 9.x. Compare with what your build runs.
java -version
./gradlew --version2Fix
Run the build on a Java version in the supported range, or move to a Spring Boot release that supports the Java and Gradle you have. Update the wrapper if Gradle is the old part.
./gradlew wrapper --gradle-version 9.0.03Verify
Start the application again.
./gradlew bootRunConfirmed by docs.spring.io
Cause 2 of 3
Spring library versions do not match the Spring Boot BOM
1Check
Spring Boot manages versions through its BOM, so starters need no version number. A version set by hand, or an ext property override, can pull a library that does not fit the Boot release.
./gradlew dependencies --configuration runtimeClasspath | grep -i spring2Fix
Remove hand-written versions of managed libraries. If you must change one, use the documented property or resolution strategy, and remember that each Boot release is tested with its own set of versions.
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
}3Verify
Run the dependency report again; all Spring Boot libraries should share the release you chose.
./gradlew dependencies --configuration runtimeClasspath | grep -i spring-bootConfirmed by docs.spring.io
Cause 3 of 3
A data source is configured, but not in the way the app expects
1Check
Without spring.datasource.url, Spring Boot tries to set up an embedded database. For a server-managed data source you use spring.datasource.jndi-name instead of url, username and password.
grep -rn "spring.datasource" src/main/resources/2Fix
Set the URL (and credentials) for a normal database, or set the JNDI name for a server-managed one. If your app does not use a database at all, exclude the data source auto-configuration.
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class MyApplication { }3Verify
Start the application and check the log for the next error, if any.
./gradlew bootRunConfirmed by docs.spring.io
How do I stop it coming back?
- Let the Spring Boot plugin and BOM choose versions of managed libraries.
- Upgrade Spring Boot, Java and Gradle together, and read the system requirements page first.
- Run the app with --debug after a dependency change to see the conditions report.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
- Nuclear Home VideoA video-streaming Android app built from scratch, engineered for smooth playback.
Related fixes
Back end
A scanner flags jackson-databind: how to upgrade it in Gradle
jackson-databind vulnerability reported by a dependency scanner
Find where the old jackson-databind comes from, then raise it.
3 causes, each with a fixBack end
Gradle cannot resolve spring-boot-gradle-plugin after a Spring Boot 3 upgrade
Plugin [id: 'org.springframework.boot', version: '3.0.1'] was not found in any of the following sources
Spring Boot 3 needs Java 17 or newer and a recent Gradle, and its Gradle plugin is published on the Gradle Plugin Portal.
3 causes, each with a fixBack end
bootJar cannot find the main class of a Spring Boot project
Main class name has not been configured and it could not be resolved
The Spring Boot Gradle plugin looks in the main source set's output for a class with a public static void main method.
2 causes, each with a fixBack end
Swagger UI URL shows the Whitelabel Error Page in Spring Boot
Whitelabel Error Page when opening /swagger-ui.html
The Whitelabel page means Spring found no handler for that address.
3 causes, each with a fixBack end
Spring Boot will not start because port 8080 is already taken
Action: Identify and stop the process that's listening on port 8080 or configure this application to listen on another port.
Spring Boot listens on 8080 unless told otherwise, and only one process can own a port.
3 causes, each with a fixBack end
Spring Boot cannot load the MySQL JDBC driver class
Cannot load driver class: com.mysql.jdbc.Driver
Spring Boot checks that the driver class you name can be loaded before it builds the connection pool.
3 causes, each with a fix