cacheable 表达式,Spring @Cacheable with SpEL键:始终计算为null

I am having a problem with @Cacheable and using a custom key based on Spring expression language. I have the following code

@Cacheable(value = "myCache", key = "#providerDTO.identifier")

ClientVO loadClientVOByProviderDTO(ProviderDTO providerDTO);

This is throwing the following error

org.springframework.expression.spel.SpelEvaluation Exception: EL1007Epos 0): Field or property 'identifier' cannot be found on null

The providerDTO argument is not null, I have verified this many times. The docs say that this should work so I am very confused. The docs give the following example

@Cacheable(value="books", key="#isbn.rawNumber")

I have also tried with a static method. This throws a NullPointerException because the providerDTO is null here.

public static String cacheKey(ProviderDTO providerDTO)

{

return providerDTO.identifier + "-" + providerDTO.clientID + "-" + providerDTO.clubID;

}

How can I debug this to find out what is happening? This is Spring 3.2.4-RELEASE. The @Cacheable tag is on an interface, but I am using standard spring AOP and not AspectJ so as far as I understand this should still work fine.

解决方案

Possible duplicate of SpelEvaluationException: EL1007E:(pos 43): Field or property 'group' cannot be found on null and spring @Cacheable with Ehcache, spel find null for valid object – I believe you compile without debug information. Please check your Maven configuration; you might want to post the relevant bits here. Search your POM (or parent POM) for the maven-compiler-plugin and a line such as:

false

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值