提问人:Nuñito Calzada 提问时间:10/22/2023 更新时间:10/22/2023 访问量:46
使用 Caffeine 在 Spring Boot 中缓存 - 根据输出控制缓存
Caching in Spring Boot with Caffeine - control the caching based on the output
问:
我有这个注释:
@CachePut(value="dogsInHouse", unless="#result!=null && #result.desc!=null && result.title!=null")
public DogInHouseResponse getDogInHouseFromDB (String key) throws ExecutionException {
..
}
但我有这个错误:
2023-10-22 10:22:25.644 ERROR [] o.a.c.c.C.[.[.[.[dispatcherServlet]@log(175) - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'result' cannot be found on object of type 'org.springframework.cache.interceptor.CacheExpressionRootObject' - maybe not public or not valid?] with root cause
org.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'result' cannot be found on object of type 'org.springframework.cache.interceptor.CacheExpressionRootObject' - maybe not public or not valid?
at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:222)
at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:105)
at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:93)
at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:59)
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:95)
at org.springframework.expression.spel.ast.OpNE.getValueInternal(OpNE.java:43)
at org.springframework.expression.spel.ast.OpNE.getValueInternal(OpNE.java:33)
at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:212)
at org.springframework.expression.spel.ast.OpAnd.getBooleanValue(OpAnd.java:57)
at org.springframework.expression.spel.ast.OpAnd.getValueInternal(OpAnd.java:52)
at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:119)
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:309)
at org.springframework.cache.interceptor.CacheOperationExpressionEvaluator.unless(CacheOperationExpressionEvaluator.java:113)
at org.springframework.cache.interceptor.CacheAspectSupport$CacheOperationContext.canPutToCache(CacheAspectSupport.java:783)
at org.springframework.cache.interceptor.CacheAspectSupport$CachePutRequest.apply(CacheAspectSupport.java:835)
at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:430)
at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:345)
at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:64)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:756)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708)
答:
1赞
phuongnq1995
10/22/2023
#1
是公开的吗?如果没有,请尝试和desc
title
getDesc()
getTitle()
评论