单独使用 @CacheInvalidate出现 Cache operation aborted because can't find cached definition 问题
- Dominant language
- Java
- Stars
- 5.6k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
单独使用 @CacheInvalidate 会出现异常,问题如何解决,访问/test/c 接口 示例如下:
@EnableMethodCache(basePackages="org.iam")
public class IamApplication {
public static void main(String[] args) {
SpringApplication.run(IamApplication.class, args);
}
}
@RestController
@RequestMapping("/test")
public class TestController {
@CacheInvalidate(name = "ccccc")
@GetMapping("/c")
public String c() {
return "ffff";
}
}
错误如下:
2025-02-21 11:25:48.625 ERROR 6384 --- [ XNIO-1 task-1] c.a.jetcache.anno.support.CacheContext : Cache operation aborted because can't find cached definition
com.alicp.jetcache.CacheConfigException: can't find cache definition with area=default name=ccccc, specified in public java.lang.String org.iam.controller.TestController.c()
at com.alicp.jetcache.anno.support.CacheContext.createOrGetCache(CacheContext.java:65) ~[jetcache-anno-2.7.4.jar:na]
at com.alicp.jetcache.anno.support.CacheContext.lambda$createCacheInvokeContext$0(CacheContext.java:46) ~[jetcache-anno-2.7.4.jar:na]
at com.alicp.jetcache.anno.method.CacheHandler.doInvalidate(CacheHandler.java:157) ~[jetcache-anno-2.7.4.jar:na]
at com.alicp.jetcache.anno.method.CacheHandler.doInvalidate(CacheHandler.java:152) ~[jetcache-anno-2.7.4.jar:na]
at com.alicp.jetcache.anno.method.CacheHandler.invokeWithInvalidateOrUpdate(CacheHandler.java:121) ~[jetcache-anno-2.7.4.jar:na]
at com.alicp.jetcache.anno.method.CacheHandler.doInvoke(CacheHandler.java:109) ~[jetcache-anno-2.7.4.jar:na]
at com.alicp.jetcache.anno.method.CacheHandler.invoke(CacheHandler.java:99) ~[jetcache-anno-2.7.4.jar:na]
at com.alicp.jetcache.anno.aop.JetCacheInterceptor.invoke(JetCacheInterceptor.java:91) ~[jetcache-anno-2.7.4.jar:na]
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the failure by calling /test/c with @CacheInvalidate(name="ccccc"), then inspect CacheContext.java:65 and CacheHandler.java:152-157 from the stack trace. Determine the expected behavior for a standalone invalidation and verify that the endpoint no longer reports the missing cached-definition error after the issue is resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100