我想@EventListener
在代理对象上使用带有条件属性的注释。EL 表达式使用函数的参数。但是在运行期间,org.springframework.core.LocalVariableTableParameterNameDiscoverer
无法从 CGLIB 生成的代理读取调试信息,这就是无法访问参数的原因。结果我得到
org.springframework.expression.spel.SpelEvaluationException: EL1007E:(pos 92): 在 null 上找不到属性或字段“prop”
class InterestedInEvent {
@EventListener(classes = SomeEvent.class, condition="#event.prop!=null")
@CacheEvict(cacheNames = CACHE_FOR_SOMETHING, allEntries = true)
public void onEvent(SomeEvent event) {
logger.debug("Chache {} has been cleaned, event={}", CACHE_FOR_SOMETHING, event);
}
}
如何公开参数名称或如何让 spring 分析原始类而不是代理?