Spring @Cacheable当返回值为null时报错解决方案
发布日期:2021-06-28 18:43:40 浏览次数:2 分类:技术文章

本文共 310 字,大约阅读时间需要 1 分钟。

如下面代码所示,@Cacheable注解的unless属性已经为我们提供好了解决方案。

unless = "#result == null" 的意思就是,当返回值为null时,就不缓存

@Cacheable(cacheNames = {"single_book"},key = "#root.targetClass+'.'+#root.methodName+'.'+#p0",            unless = "#result == null")    public Book getBook(Long id){        return bookMapper.selectBookById(id);    }

 

转载地址:https://blog.csdn.net/xl_1803/article/details/112114631 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:小数在计算机中如何存储?
下一篇:Linux设置上网代理服务器

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.219.124.196]2024年04月03日 13时47分30秒