![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
项目 中的优秀代码
哈喽,树先生
go go go
展开
-
Redisson延时队列搭建及使用
redisson 实现延时队列消费原创 2023-01-14 16:07:42 · 656 阅读 · 0 评论 -
2.读取动态拼接key的配置文件属性值
0.要读取的配置文件 server: port: 8999 hc: test1: test1111 test2: test2222 1.通过Environment读取 @Autowired private Environment env; /** * 可以根据拼接条件读取配置文件中的值 * @return */ @RequestMapping("/read1") public String readYml1(int i)原创 2021-10-22 11:12:05 · 159 阅读 · 0 评论 -
5.java异步执行设置
一.springboot项目默认异步执行 @EnableAsync // 使用异步方法时需要提前开启(在启动类上或配置类上) @Async // 被async注解修饰的方法由SpringBoot默认线程池(SimpleAsyncTaskExecutor)执行 二.springboot自定义线程池 1.配置自定义线程池 import org.springframework.context.annotation.Bean; import org.springframework.context.annotati原创 2021-10-22 10:48:09 · 922 阅读 · 0 评论 -
1.项目中高级编码之jdk8特性运用
1.代码分解:判断supportAreasTemp是否为null,不为null则 将supportAreasTemp集合按指定长度10进行切分,分割后再依次遍历 Lists.partition(Optional.ofNullable(supportAreasTemp).orElse(Collections.emptyList()), 10).forEach(partition -> { partition.stream().forEach(supportArea -> {原创 2021-06-08 22:47:23 · 101 阅读 · 0 评论 -
1.项目中高级编码之缓存get/set
根据用户id和appId查找用户UserToken,为空则去数据库查找后刷入缓存,不为空则直接返回缓存值。 public UserToken getUserTokenByUserId(Long userId, Integer appId){ String cacheKey = CacheConstant.CACHE_USER_TOKEN_USERID_APPID + userId + "_" + appId; return new CacheGetCallBack&l原创 2021-06-08 22:44:52 · 168 阅读 · 0 评论