微服务开发系列:怎样在框架中选择开源工具
在该框架中,已经包含了绝大多数开发所需要的工具类。
1 工具类使用步骤先查找 hutool 中有没有,如果没有,下一步找已经存在的 jar 包是否已经存在,如果不存在或不合适(例如来源于非专业解决这类问题的工具类),下一步考虑自己实现,如果难度过大,下一步引入其它依赖实现,这是最后一步才需要考虑的,进行这一步之前,反复确认前三步是否都做到位了在引入第三方工具类、新建自己的工具类之前请三思!2 本地缓存使用 com.github.ben-manes.caffeine
,spring gateway 官方推荐使用。
使用 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加密
版权声明
本文仅代表作者观点,不代表博信信息网立场。
上一篇:怎么注册虚拟主机 下一篇:qt两个窗口怎么传递数据