在该框架中,曾经蕴含了绝大多数开发所须要的工具类。

1 工具类应用步骤

  1. 先查找 hutool 中有没有,如果没有,下一步
  2. 找曾经存在的 jar 包是否曾经存在,如果不存在或不适合(例如来源于非专业解决这类问题的工具类),下一步
  3. 思考本人实现,如果难度过大,下一步
  4. 引入其它依赖实现,这是最初一步才须要思考的,进行这一步之前,重复确认前三步是否都做到位了
在引入第三方工具类、新建本人的工具类之前请三思!

2 本地缓存

应用 com.github.ben-manes.caffeine,spring gateway 官网举荐应用。

3 分布式缓存

应用 redisson,惟一指定应用的 redis 客户端,你能想到的性能都能在这里找到。

4 根底工具类

大部分根底工具类都来源于 hutool。

hutool 蕴含了绝大多数你能想到的工具类。

然而因为 kotlin 的引入,某些对于文件或者是字符的解决,应用 kotlin 提供的形式会更加不便。

比方字符串解决、线程工具、汇合解决、日期解决、文件解决、验证码生成、md5、类解决、各类加密等等等等。

在我的项目根目录下执行 grep -hr "import cn.hutool" * | sort | uniq,获取我的项目所有用到的工具类,有如下后果:

import cn.hutool.captcha.CaptchaUtil;                    //验证码工具类import cn.hutool.captcha.LineCaptcha;                    //验证码工具类import cn.hutool.core.bean.BeanUtil;                    //实体类解决import cn.hutool.core.codec.Base64;                        //base64工具import cn.hutool.core.collection.CollUtil;            //汇合工具类import cn.hutool.core.date.LocalDateTimeUtil;        //日期解决import cn.hutool.core.date.StopWatch;                    //耗时记录import cn.hutool.core.exceptions.ExceptionUtil; //异样工具import cn.hutool.core.io.FileUtil;                        //文件工具import cn.hutool.core.io.IoUtil;                          //io流解决import cn.hutool.core.lang.Editor;                        //实体类解决import cn.hutool.core.map.MapUtil;                        //map工具类import cn.hutool.core.text.CharSequenceUtil;        //字符串工具类import cn.hutool.core.thread.ThreadUtil;              //线程工具类import cn.hutool.core.util.ArrayUtil;                    //数组工具类import cn.hutool.crypto.asymmetric.KeyType;            //加密import cn.hutool.crypto.asymmetric.SM2;                  //sm2国密加密import cn.hutool.crypto.digest.BCrypt;                  //BCrypt加密