When using Spring Boot with the dependency management plugin, users are supposed to be able to specify dependencies without a version and the Spring Boot managed version will be used. This usually works well. However, with SB 3.1 I have found that it fails to resolve the ehcache dependency when used without specifying a version.

This is a sample build.gradle file that fails:

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.1.3'
    id 'io.spring.dependency-management' version '1.1.3'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'

java {
    sourceCompatibility = '17'
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-cache'
    implementation 'org.ehcache:ehcache'

    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

tasks.named('test') {
    useJUnitPlatform()
}

If I run a build using this file I get the following error message:

$ ./gradlew build
> Task :compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
   > Could not find org.ehcache:ehcache:.
     Required by:
         project :

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 3s
1 actionable task: 1 executed

This used to work with SB 2.7, and still works for other dependencies that I use. For some reason, the ehcache dependency is not working with SB dependency management.

Comment From: scottfrederick

Duplicates #33395. Please see the note in the Spring Boot 3.0 migration guide.

Comment From: shollander

I see it now. Not sure how I missed it earlier. I even did a search of open tickets before submitting this, but didn't see that other ticket since it was closed. Another thing that confused me was that if I use the version number (without the classifier) it works. But it all makes sense now. Thanks!

Comment From: shollander

@scottfrederick I tried adding the classifier, but it still doesn't work. I tried both

implementation 'org.ehcache:ehcache::jakarta'

and

implementation (group: 'org.ehcache', name: 'ehcache', classifier: 'jakarta')

Neither work unless I also add the version. I am using the latest version of Gradle (8.3) and Spring Boot (3.1.3).

Comment From: wilkinsona

Gradle's support for working with classifiers is rather limited. Specifically, there's no way for a dependency's version to only be managed if it has a matching classifier. This limitation led to the dependency management plugin having to ignore dependency management with a classifier.

In this case, the classified and unclassified dependency both have the same version. If Boot provided dependency management for both, things would work as desired. We should do this for ehcache and ehcache-transactions, both of which are currently only managed in their classified form.