Skip to content

Improve exception message in case of incomplete Caching configuration. [SPR-12898] #17497

@spring-projects-issues

Description

@spring-projects-issues

Thomas Darimont opened SPR-12898 and commented

If a user declares multiple CacheManager's without declaring one of them as @Primary and without using a CacheResolver the following Exception is thrown during bootstrap:

java.lang.IllegalStateException: No CacheResolver specified, and no unique bean of type CacheManager found. Mark one as primary or declare a specific CacheManager to use.

In the linked example gist I had two CacheManager's and a Service with two operations where each operation was explicitly referring to a CacheManager. So from looking at the code it seemed that everything was setup correctly.

We should enhance the exception message to make clear that a CacheManager needs to be the "default" one in case no additional configuration is present etc.

How about:

No CacheResolver specified, and no unique bean of type CacheManager found. Mark one as primary (or give it the name cacheManager) or declare a specific CacheManager to use, that serves as the default one.

Affects: 4.1.6

Reference URL: https://gist.github.com/thomasdarimont/b855ae97708d4d8c3c1f

Referenced from: commits e5b5052

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions