spring-bootgradleehcache-3

Gradle could not find org.ehcache:ehcache:. after upgrading to Spring Boot 3.0.x


I'm currently in the progress of upgrading a Spring Boot Gradle project from 2.7.x to 3.0.x. In this project we've declarated the Ehcache library as a API dependency:

api 'org.ehcache:ehcache'

After reading the migration guide, I've changed this to the following:

api('org.ehcache:ehcache') {
    capabilities {
        requireCapability('org.ehcache:ehcache-jakarta')
    }
}

However after running ./gradlew build, Gradle failed to resolve the dependency:

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 :

I've tried the following possible workarounds:

api 'org.ehcache:ehcache-jakarta'

Does not work.

api 'org.ehcache:ehcache:jakarta'

Does not work.

However, when declaring a version it does work:

api 'org.ehcache:ehcache:3.10.8:jakarta'

But why declare a version if this is managed by Spring Boot?

Spring Boot version: 3.0.4 Gradle Wrapper version: 7.6.1


Solution

  • You can configure a dependency with a classifier and without a version like this:

    api("org.ehcache:ehcache::jakarta")
    

    Note the :: that omits the version.

    For Spring Boot's dependency management to apply correctly in this instance, you'll have to use Gradle's built-in platform support rather than the dependency management plugin:

    api(platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES))