Skip to content

Allow custom CacheResolver to be configured #5201

Closed
@snicoll

Description

@snicoll

The current CacheAutoConfiguration has the following condition: @ConditionalOnMissingBean({ CacheManager.class, CacheResolver.class }). If you want to configure your own custom CacheResolver, something along the lines of

@Bean
@Lazy
public CacheResolver fooBarCacheResolver(CacheManager cacheManager) {
    return new AbstractCacheResolver(cacheManager) { ... }
}

Then it blows up because the CacheManager is no longer configured. And it isn't because we've defined a CacheResolver.

But we haven't configured the CacheResolver: we just have configured a CacheResolver that can be used in a dedicated service.

Maybe we should use a bean name rather than a type.

The exception is also misleading:

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions