我有这样的注解:

@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)

推荐答案

desctitle是公开的吗?如果没有,请try getDesc()getTitle()

Java相关问答推荐

ActivityCompat.请求收件箱自动拒绝权限

我可以从Java模块中排除maven资源文件夹吗?

Java 22模式匹配不适用于记录模式匹配.给出汇编问题

如果给定层次 struct 级别,如何从其预序穿越构造n元树

Android Studio—java—在onBindViewHolder中,将断点和空白添加到BackclerView中

neo4j java驱动程序是否会在错误发生时自动回滚事务?

为什么JAVA&S清洁器使用链表而不是并发HashSet?

在Java中,如何按一个属性升序,然后按另一个属性降序对对象列表进行排序?

如何仅使用键/ID的一部分(组合)高效地返回映射值?

在执行流和相关操作时,使用Java泛型为2个方法执行相同的操作,但对象不同

从映射列表中检索所有键

为什么在下面的Java泛型方法中没有类型限制?

如何在字节数组中反转UTF-8编码?

Java.time.OffsetDateTime的SQL Server数据库列类型是什么?

如何制作回文程序?

字符串的Gzip压缩在java11和java17中给出了不同的结果

升级版本后出现非法访问错误

将@Transactional添加到Spring框架中链下的每个方法会产生什么效果?

具有 DayOfWeek 列表的 JPA 实体

在java中使用SevenZip.openArchive方法后无法删除文件