我在使用 @Cacheable 和使用基于 Spring 表达式语言的自定义键时遇到问题。我有以下代码
@Cacheable(value = "myCache", key = "#providerDTO.identifier")
ClientVO loadClientVOByProviderDTO(ProviderDTO providerDTO);
这引发了以下错误
org.springframework.expression.spel.SpelEvaluation Exception: EL1007Epos 0): Field or property 'identifier' cannot be found on null
providerDTO 参数不为空,我已经验证过很多次了。文档说这应该有效,所以我很困惑。文档给出了以下示例
@Cacheable(value="books", key="#isbn.rawNumber")
我也尝试过静态方法。这会引发 NullPointerException,因为这里的providerDTO 为null。
public static String cacheKey(ProviderDTO providerDTO)
{
return providerDTO.identifier + "-" + providerDTO.clientID + "-" + providerDTO.clubID;
}
我如何调试它以找出发生了什么?这是 Spring 3.2.4-RELEASE。 @Cacheable 标签位于接口上,但我使用的是标准 spring AOP 而不是 AspectJ,因此据我了解,这应该仍然可以正常工作。
可能重复的SpelEvaluationException:EL1007E:(位置43):在空值上找不到字段或属性“组” https://stackoverflow.com/q/22959459/2621917 and spring @Cacheable 与 Ehcache,spel 查找有效对象为 null https://stackoverflow.com/q/24301074/2621917– 我相信你编译时没有调试信息。请检查您的 Maven 配置;您可能想在这里发布相关内容。在您的 POM(或父 POM)中搜索maven-compiler-plugin
和一行,例如:
<debug>false</debug>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)