diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java index eb742122d0..4616abcc08 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java @@ -670,8 +670,10 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker private Object generateKey(CacheOperationContext context, @Nullable Object result) { Object key = context.generateKey(result); if (key == null) { - throw new IllegalArgumentException("Null key returned for cache operation (maybe you are " + - "using named params on classes without debug info?) " + context.metadata.operation); + throw new IllegalArgumentException(""" + Null key returned for cache operation [%s]. If you are using named parameters, \ + ensure that the compiler uses the '-parameters' flag.""" + .formatted(context.metadata.operation)); } if (logger.isTraceEnabled()) { logger.trace("Computed cache key '" + key + "' for operation " + context.metadata.operation);