http://xiangai.taobao.com
http://shop148612228.taobao.com

cannot be found on object of type 'org.springframework.cache.interceptor.CacheExpressionRootObject' - maybe not public


Cannot find cache named for Builder[public java.u Property or field cannot be found on object of type 'org.springframework.cache.interceptor.CacheExpressionRootObject' - maybe not public

key如果是常量必须用单引号引起来: key ="'keyStrijng'";


key拼接语法:
@Cacheable(value = "page_user",key ="T(String).valueOf(#page).concat('-').concat(#pageSize)",unless = "#result=null")//由于page是int型,concat要求变量必须为String,所以强转一下
@Override
public List<SysUserEntity> page(int page, int pageSize) {
return userMapper.page(page,pageSize);
}
}


补充:记一个spring缓存Cacheable注解key设置问题

spring的Cacheable注解用来设置缓存,其中的key属性为spel表达式,如果要设置常量,则需要用''包裹,如:

1
@Cacheable(value = CacheConstant.APPLICATION,key = "'id_map'")


此处的"'id_map'"代表key设置了一个常量,如果没有'',则会报错

org.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'lang_code_map' cannot be found on object of type 'org.springframework.cache.interceptor.CacheExpressionRootObject' - maybe not public or not valid?

意思为在缓存表达式根对象上找不到指定属性,说明如果不加'',则id_map作为属性解析

posted @ 2022-02-27 11:14  万事俱备就差个程序员  阅读(1017)  评论(0编辑  收藏  举报

http://xiangai.taobao.com
http://shop148612228.taobao.com
如果您觉得对您有帮助.领个红包吧.谢谢.
支付宝红包
微信打赏 支付宝打赏