This generates an error saying I create a circular dependency.
@Configuration
@EnableCaching
public class MyConfig {
@Bean
public Cache cache(CacheManager cacheManager) {
return cacheManager.getCache("acl_cache");
}
}
But when I do this, it works:
@Configuration
@EnableCaching
public class MyConfig {
@Bean
public MyClass myClass(CacheManager cacheManager) {
Cache cache = cacheManager.getCache("acl_cache");
return new MyClass(cache);
}
}
In both cases I made a new cache, but in the first case it's a bean.
Why do spring boot thinks this is a circular dependency in one case, and not in the other?
PS: MyClass is not important here. In reality I use SpringCacheBasedAclCache who needs more parameters