ehcache+springmvc 4.3 在使用@cacheable时出错

xierfly 2017-06-09 06:56:04
<!-- spring cache 配置 -->
<!-- 启用缓存注解功能,这个是必须的,否则注解不会生效,另外,该注解一定要声明在spring主配置文件中才会生效 -->
<cache:annotation-driven cache-manager="cacheManager"/>

<!-- 配置缓存管理器,获取cache -->
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="ehCacheFactory"/>
</bean>

<!-- 配置Ehcache缓存管理器,读取配置文件 -->
<bean id="ehCacheFactory" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="classpath:ehcache.xml"/>
<property name="shared" value="true"/>
</bean>



我的SearchModel是一个实体,并且也实现了equal 、hashcode了;

方法传入方式如下:
leadsCombineChartsStatList(@ModelAttribute SearchModel searchModel, Integer start, Integer length)
{
// 其他code
leadsChartService.selectCombineEachDayLeads(searchModel);
// 其他code
}

不起作用的cacheable
@Cacheable(value = "leadsChartCache", key = "#searchModel.getBeginTime()+searchModel.getEndTime()", unless = "#searchModel==null")
@Override
public List<LeadsCombineChartViewModel> selectCombineEachDayLeads(SearchModel searchModel)

报错内容:
Property or field 'searchModel' cannot be found on object of type 'org.springframework.cache.interceptor.CacheExpressionRootObject' - maybe not public?

另外试了一下,改正这样的,也是报同样的错误:
@Cacheable(value = "leadsChartCache", key = "#root.targetClass+root.methodName")




...全文
460 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

3,424

社区成员

发帖
与我相关
我的任务
社区描述
其他开发语言 其他开发语言
社区管理员
  • 其他开发语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧