-
Notifications
You must be signed in to change notification settings - Fork 583
Spring 4.3.7 and ehcache 3.3.1 can't autowire cache manager #1994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Please use StackOverflow or our mailing list to ask such questions. Spring supports Ehcache 2 and 3. The Have a look here to see an example. |
If I used ehcache.xml in the application still I need to programatically create cache manager bean and need to create cache objects? |
@chandrasekhar4u you can use either jsr-107 api or ehcache3 api to load an ehcache.xml and retrieve your CacheManager and Caches from it : |
To use only configuration you can do something similar to: application.properties
App.java:
Assuming you have The |
@henri-tremblay Thank you for the reply, I tried the same, and I autowired cacheManager in one of my spring service. How can I access cacheManager and cache objects from it? (how application will come to know which cache manager implementation to invoke?) |
You can use If that's already the case, I would need a full stack trace to help you. |
That's the key for me:
Thanks @henri-tremblay. |
I am using Spring boot 1.5.2.RELEASE, Spring 4.3.7, ehcache 3.3.1 in my application,
ehcache.xml
application.properties
spring.cache.jcache.config=classpath:ehcache.xml
spring.cache.cache-names=mayCache1,mayCache2,mayCache3
spring.cache.caffeine.spec=maximumSize=1000,expireAfterAccess=600s
pom.xml dependencies:
When I try to access cache manager in CacheConfiguration class it's throwing error like below:
Unsatisfied dependency expressed through field 'cacheManager'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.cache.CacheManager' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
While debugging I observed that EhCacheCacheManager is getting called and trying to autowire net.sf.ehcache.CacheManager cacheManager from it.
I am not able to understand why spring 4.3.x has old version of CacheManager instance of Ehcache, and not able to inject/autowire object. Please help me to solve this issue.
The text was updated successfully, but these errors were encountered: