redheaddev
redheaddev

Reputation: 11

Does Spring Framework 6.x support Jcache (JSR 107) implementation (javax.cache:cache-api:1.1.1)?

I'm looking to make an upgrade to a Spring backend project, moving from Spring 5.3 to Spring 6.1. Since this upgrade requires migrating from Javax to a Jakarta namespace, I was looking into some of the dependencies of this project.

At the moment, Jcache (javax.cache:cache-api:1.1.1) and Ehcache (org.ehcache:ehcache:3.10.0) are being used to handle the caching for the project and is setup within a @Configuration class using the javax CacheManager.

What I'm trying to determine is whether the current gradle dependency (javax.cache:cache-api:1.1.1) is usable within Spring Framework 6.1.1, or if I need to update/replace this and implement Jcache differently. Any insight would be appreciated!

Since Jcache is Javax based, I tried researching to see if it was compatible with Spring 6.1 and Jakarta EE, as I know some Javax packages are still available for use on Jakarta platforms. However, it doesn't seem very clear to me, as a lot of articles I have read talk about the Spring Boot Cache dependency, however this project is not implementing Spring Boot. I also searched the Spring Docs, and I see mention of JSR 107 support, but nothing about this specific dependency implementation (javax.cache:cache-api).

Upvotes: 1

Views: 3126

Answers (1)

Laurent Schoelens
Laurent Schoelens

Reputation: 2848

From what I've seen (source here), EhCache has runtime dependency of jaxb-runtime 2.x which is javax based.

javax.cache:cache-api itself depends (optional) of the javax.entreprise:cdi-api but since this dependency is optional it shouldn't be a problem.

My guess is you should switch to another cache system if using ehcache.
I personnaly use Caffeine, and they talk about JSR107 / JCache in their wiki

EDIT based on comment (thanks to redheaddev)

Ehcache variant with jakarta classifier exists from version 3.10.
With this classifier, it depends on jaxb jakarta-based version, so a simple update should do the trick if application does not depend on cdi-api.

Upvotes: 0

Related Questions