Skip to content
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

java.lang.IllegalStateException: No CacheResolver specified, and no bean of type CacheManager found. Register a CacheManager bean or remove the @EnableCaching annotation from your configuration. #138

Open
Blackbaud-JasonBodnar opened this issue May 24, 2022 · 2 comments

Comments

@Blackbaud-JasonBodnar
Copy link

I have @EnableCaching on my application class.

In application.properties I have:

# caching
coffee-boots.cache.spec.reCountries=expireAfterWrite=3d,expireAfterAccess=1d,maximumSize=500
coffee-boots.cache.spec.reInstalledCountries=expireAfterWrite=3d,expiresAfterAccess=1d,maximumSize=500

But when I try to run a test or boot my application I get:

java.lang.IllegalStateException: No CacheResolver specified, and no bean of type CacheManager found. Register a CacheManager bean or remove the @EnableCaching annotation from your configuration.

If I add a bean with a CacheManager:

@Bean
public CacheManager cacheManager() {
    return new MultiConfigurationCacheManager();
}

My application runs but it doesn't look like my cache is configured per the .properties file:

@Autowired
CacheManager cacheManager
...
cacheManager.getCache("reCountries")

gives me:

result = {org.springframework.cache.caffeine.CaffeineCache@20802} 
 allowNullValues = true
 cache = {com.github.benmanes.caffeine.cache.UnboundedLocalCache$UnboundedLocalManualCache@20804} 
  cache = {com.github.benmanes.caffeine.cache.UnboundedLocalCache@20807}  size = 1
  policy = null
 name = "reCountries"

Do I need to provide a CacheManager bean or does coffee-boots do that for me already? If it does, what am I doing wrong that causes the error I'm getting?

@stepio
Copy link
Owner

stepio commented May 26, 2022

Hello @Blackbaud-JasonBodnar !

Sorry that you have this problem. Which versions of Spring & Spring Boot do you use?

@Blackbaud-JasonBodnar
Copy link
Author

Spring 5.3.20
Spring Boot 2.6.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants