摘要: 1. 功能说明 除了填充缓存,spring cache 也支持使用 @CacheEvict 来删除缓存。@CacheEvict 就是一个触发器,在每次调用被它注解的方法时,就会触发删除它指定的缓存的动作。跟 @Cacheable 和 @CachePut 一样,@CacheEvict 也要求指定一个或 阅读全文
posted @ 2022-02-15 11:11 全琪俊 阅读(544) 评论(0) 推荐(0) 编辑
摘要: 从3.1开始,Spring引入了对Cache的支持。其使用方法和原理都类似于Spring对事务管理的支持。Spring Cache是作用在方法上的,其核心思想是这样的:当我们在调用一个缓存方法时会把该方法参数和返回结果作为一个键值对存放在缓存中,等到下次利用同样的参数来调用该方法时将不再执行该方法, 阅读全文
posted @ 2022-02-15 11:09 全琪俊 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 注释介绍 redis与Spring Cache的整合请参看上章 @Cacheable @Cacheable 的作用 主要针对方法配置,能够根据方法的请求参数对其结果进行缓存 @Cacheable 作用和配置方法 参数解释example value 缓存的名称,在 spring 配置文件中定义,必须指 阅读全文
posted @ 2022-02-15 11:07 全琪俊 阅读(304) 评论(0) 推荐(0) 编辑
摘要: 接收方法中的注解常见注解: @PathVariable(路径变量)注解的使用带占位符的 URL 是 Spring3.0 新增的功能,该功能在SpringMVC 向 REST 目标挺进发展过程中具有里程碑的意义。@PathVariable(“xxx”)通过 @PathVariable 可以将URL中占 阅读全文
posted @ 2022-02-15 11:04 全琪俊 阅读(552) 评论(0) 推荐(0) 编辑
摘要: //java8去重List<User> userList = new ArrayList<User>();buildUserList = buildUserList.stream().collect( Collectors.collectingAndThen(Collectors.toCollect 阅读全文
posted @ 2022-02-15 09:58 全琪俊 阅读(1309) 评论(0) 推荐(0) 编辑
摘要: 常用方式 list.stream().collect(Collectors.toMap(v -> StrUtil.isNotBlank(v.getAreaName())?StrUtil.replace(v.getAreaName(),"区","").replace("管委会",""):"", v-> 阅读全文
posted @ 2022-02-15 09:54 全琪俊 阅读(870) 评论(0) 推荐(0) 编辑
摘要: Collectors.groupingBy根据一个或多个属性对集合中的项目进行分组 数据准备: public Product(Long id, Integer num, BigDecimal price, String name, String category) { this.id = id; t 阅读全文
posted @ 2022-02-15 09:47 全琪俊 阅读(478) 评论(0) 推荐(0) 编辑