hutool/README.md

231 lines
11 KiB
Markdown
Raw Normal View History

2023-04-28 00:43:27 +08:00
<p align="center">
2023-04-28 00:37:50 +08:00
<a href="https://hutool.cn/"><img alt="" src="https://plus.hutool.cn/images/hutool.svg" width="45%"></a>
2021-01-20 17:10:45 +08:00
</p>
2023-04-28 00:43:27 +08:00
<p align="center">
2023-04-16 00:54:24 +08:00
<strong>🍬Make Java Sweet Again.</strong>
2021-01-20 17:10:45 +08:00
</p>
2023-04-28 00:43:27 +08:00
<p align="center">
2021-04-22 03:46:58 +08:00
👉 <a href="https://hutool.cn">https://hutool.cn/</a> 👈
2021-01-20 17:10:45 +08:00
</p>
2023-04-28 00:43:27 +08:00
<p align="center">
2023-04-03 19:26:12 +08:00
<a target="_blank" href="https://search.maven.org/artifact/org.dromara.hutool/hutool-all">
2023-04-28 00:37:50 +08:00
<img alt="" src="https://img.shields.io/maven-central/v/org.dromara.hutool/hutool-all.svg?label=Maven%20Central" />
2021-01-20 17:10:45 +08:00
</a>
2023-07-27 15:12:49 +08:00
<a target="_blank" href="https://license.coscl.org.cn/MulanPSL2">
2023-04-28 00:37:50 +08:00
<img alt="" src="https://img.shields.io/:license-MulanPSL2-blue.svg" />
2021-01-20 17:10:45 +08:00
</a>
2021-03-15 11:25:29 +08:00
<a target="_blank" href="https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html">
2023-04-28 00:37:50 +08:00
<img alt="" src="https://img.shields.io/badge/JDK-8+-green.svg" />
2021-01-20 17:10:45 +08:00
</a>
2021-03-21 15:19:13 +08:00
<a target="_blank" href="https://travis-ci.com/dromara/hutool">
2023-04-28 00:37:50 +08:00
<img alt="" src="https://travis-ci.com/dromara/hutool.svg?branch=v5-master" />
2021-01-20 17:10:45 +08:00
</a>
2021-03-20 18:09:21 +08:00
<a href="https://www.codacy.com/gh/dromara/hutool/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=dromara/hutool&amp;utm_campaign=Badge_Grade">
2023-04-28 00:37:50 +08:00
<img alt="" src="https://app.codacy.com/project/badge/Grade/8a6897d9de7440dd9de8804c28d2871d"/>
2021-01-20 17:10:45 +08:00
</a>
2021-03-15 11:25:29 +08:00
<a href="https://codecov.io/gh/dromara/hutool">
2023-04-28 00:37:50 +08:00
<img alt="" src="https://codecov.io/gh/dromara/hutool/branch/v6-master/graph/badge.svg" />
2021-01-20 17:10:45 +08:00
</a>
<a target="_blank" href="https://gitter.im/hutool/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge">
2023-04-28 00:37:50 +08:00
<img alt="" src="https://badges.gitter.im/hutool/Lobby.svg" />
2021-01-20 17:10:45 +08:00
</a>
2021-03-12 20:58:14 +08:00
<a target="_blank" href='https://gitee.com/dromara/hutool/stargazers'>
2023-04-28 00:37:50 +08:00
<img alt="star" src='https://gitee.com/dromara/hutool/badge/star.svg?theme=gvp'/>
2021-01-20 17:10:45 +08:00
</a>
2021-03-15 11:25:29 +08:00
<a target="_blank" href='https://github.com/dromara/hutool'>
2023-04-28 00:37:50 +08:00
<img alt="github star" src="https://img.shields.io/github/stars/dromara/hutool.svg?style=social"/>
2021-01-20 17:10:45 +08:00
</a>
</p>
<br/>
2023-04-28 00:43:27 +08:00
<p align="center">
2022-12-14 17:09:26 +08:00
<a href="https://qm.qq.com/cgi-bin/qm/qr?k=QtsqXLkHpLjE99tkre19j6pjPMhSay1a&jump_from=webapi">
2023-04-28 00:37:50 +08:00
<img alt="" src="https://img.shields.io/badge/QQ%E7%BE%A4%E2%91%A6-715292493-orange"/></a>
2021-01-20 17:10:45 +08:00
</p>
2023-11-07 11:08:27 +08:00
-------------------------------------------------------------------------------
2023-11-07 11:09:15 +08:00
2023-11-07 11:08:27 +08:00
<p align="center">
2023-11-16 22:30:45 +08:00
<a href="#"><img style="width: 45%" alt="" src="https://plus.hutool.cn/images/zanzhu.jpg"/></a>
2023-11-07 11:08:27 +08:00
</p>
2023-11-07 11:09:15 +08:00
2023-11-07 11:08:27 +08:00
-------------------------------------------------------------------------------
2021-04-20 11:51:29 +08:00
[**🌎English Documentation**](README-EN.md)
2021-01-20 17:10:45 +08:00
-------------------------------------------------------------------------------
2021-04-20 11:51:29 +08:00
## 📚简介
2022-04-28 01:59:51 +08:00
2023-04-28 00:37:50 +08:00
`Hutool`是一个功能丰富且易用的**Java工具库**,通过诸多实用工具类的使用,旨在帮助开发者快速、便捷地完成各类开发任务。
2023-07-29 16:07:04 +08:00
这些封装的工具涵盖了字符串、数字、集合、编码、日期、文件、IO、加密、数据库JDBC、JSON、HTTP客户端等一系列操作
可以满足各种不同的开发需求。
2021-01-20 17:10:45 +08:00
2023-04-28 00:37:50 +08:00
### 🎁Hutool往事
2021-01-20 17:10:45 +08:00
2023-04-28 00:37:50 +08:00
- 2012年一个刚刚步入职场的少年剥离了业务系统中的公共部分取名叫做`Common-Tools`
- 2014年他离开热爱的互联网和IT行业将这份热爱倾注于开源并将项目更名为`Hutool`
`Hu`是怀念曾经公司中一起并肩作战的小伙伴们和那段美好回忆人生难得糊涂我们都在成长但不变的是对Coding的热爱。
- 现在“他”变成“他们”——一群热心的Committer。而`Hutool`,数十年如一日已成为众多Java开发者互助的桥梁。
- 将来Make Java Sweet Again!
2021-01-20 17:10:45 +08:00
2023-04-28 00:37:50 +08:00
### 🍺Hutool理念
2021-01-20 17:10:45 +08:00
2023-04-28 00:37:50 +08:00
`Hutool`既是一个工具集,也是一个知识库,我们从不自诩代码原创,大多数工具类都是**搬运**而来,因此:
2021-01-20 17:10:45 +08:00
2023-04-28 00:37:50 +08:00
- 你可以引入使用,也可以**拷贝**和修改使用,而**不必标注任何信息**只是希望能把bug及时反馈回来。
- 我们努力健全**中文**注释,为源码学习者提供良好地学习环境,争取做到人人都能看得懂。
2021-01-20 17:10:45 +08:00
### ✨版本选择
Hutool目前主要版本4.x、5.x、6.x选择如下
| 版本 | jdk| Maven仓库 | 主要特点 |
|-----|----|--------------------------------------------------------------------------------------------------------|-------------------------------------|
| 4.x | jdk1.7 | [cn.hutool/hutool-all/4.x](https://mvnrepository.com/artifact/cn.hutool/hutool-all/4.6.17) | jdk1.7编译 |
| 5.x | jdk1.8 | [cn.hutool/hutool-all/5.x ](https://mvnrepository.com/artifact/cn.hutool/hutool-all) | jdk1.8编译,使用JavaEE,适配JDK11、17、21 |
| 6.x | jdk1.8 | [org.dromara.hutool/hutool-all/6.x ](https://mvnrepository.com/artifact/org.dromara.hutool/hutool-all) | jdk1.8编译,使用Jakarta EE,适配JDK11、17、21 |
2021-01-20 17:10:45 +08:00
2021-04-20 11:51:29 +08:00
## 🛠️包含组件
2022-04-28 01:59:51 +08:00
2023-04-28 00:37:50 +08:00
| 模块 | 介绍 |
|----------------|-------------------------------------------------|
| hutool-core | 核心包括Bean操作、日期、各种Util等 |
| hutool-cron | 定时任务模块提供类Crontab表达式的定时任务 |
| hutool-crypto | 加密解密模块,提供对称、非对称和摘要算法封装 |
| hutool-db | JDBC封装后的数据操作基于ActiveRecord思想 |
| hutool-extra | 扩展模块对第三方封装模板引擎、邮件、Servlet、二维码、Emoji、FTP、分词等 |
| hutool-http | 基于HttpUrlConnection、HttpClient、OkHttp的Http客户端封装 |
| hutool-log | 功能强大的日志门面 |
| hutool-setting | 功能更强大的配置文件封装和工具 |
| hutool-json | JSON实现 |
| hutool-poi | POI中Excel和Word的封装以及OFD封装 |
| hutool-socket | 基于Java的NIO和AIO的Socket封装 |
| hutool-swing | Swing和JWT相关封装 |
2021-01-20 17:10:45 +08:00
可以根据需求对每个模块单独引入,也可以通过引入`hutool-all`方式引入所有模块。
-------------------------------------------------------------------------------
2022-04-28 01:59:51 +08:00
## 📝文档
2021-01-20 17:10:45 +08:00
2023-12-01 18:23:08 +08:00
[📘中文文档](https://doc.hutool.cn/pages/index/)
2021-01-20 17:10:45 +08:00
2022-03-09 15:48:31 +08:00
[📘中文备用文档](https://plus.hutool.cn/docs/#/)
2021-04-20 11:51:29 +08:00
[📙参考API](https://apidoc.gitee.com/dromara/hutool/)
2021-01-20 17:10:45 +08:00
-------------------------------------------------------------------------------
2021-10-21 22:42:42 +08:00
## 🪙支持Hutool
### 💳捐赠
如果你觉得Hutool不错可以捐赠请维护者吃包辣条~,在此表示感谢^_^。
[Gitee上捐赠](https://gitee.com/dromara/hutool)
### 👕周边商店
你也可以通过购买Hutool的周边商品来支持Hutool维护哦
我们提供了印有Hutool Logo的周边商品欢迎点击购买支持
2021-12-12 18:41:43 +08:00
👉 [Hutool 周边商店](https://market.m.taobao.com/apps/market/content/index.html?wh_weex=true&contentId=331724720170) 👈
2021-10-21 22:42:42 +08:00
-------------------------------------------------------------------------------
2021-04-20 11:51:29 +08:00
## 📦安装
2021-01-20 17:10:45 +08:00
2021-04-22 03:30:56 +08:00
### 🍊Maven
2022-04-28 01:59:51 +08:00
2021-01-20 17:10:45 +08:00
在项目的pom.xml的dependencies中加入以下内容:
```xml
2022-04-28 01:59:51 +08:00
2021-01-20 17:10:45 +08:00
<dependency>
2023-04-03 19:26:12 +08:00
<groupId>org.dromara.hutool</groupId>
2022-04-28 01:59:51 +08:00
<artifactId>hutool-all</artifactId>
2024-05-29 11:57:54 +08:00
<version>6.0.0-M14</version>
2021-01-20 17:10:45 +08:00
</dependency>
```
2021-04-22 03:30:56 +08:00
### 🍐Gradle
2022-04-28 01:59:51 +08:00
2021-01-20 17:10:45 +08:00
```
2024-05-29 11:57:54 +08:00
implementation 'org.dromara.hutool:hutool-all:6.0.0-M14'
2021-01-20 17:10:45 +08:00
```
2021-04-22 03:30:56 +08:00
### 📥下载jar
2021-01-20 17:10:45 +08:00
2021-04-22 03:30:56 +08:00
点击以下链接,下载`hutool-all-X.X.X.jar`即可:
2021-01-20 17:10:45 +08:00
2024-05-29 11:57:54 +08:00
- [Maven中央库](https://repo1.maven.org/maven2/org/dromara/hutool/hutool-all/6.0.0-M14/)
2021-01-20 17:10:45 +08:00
2021-04-20 11:51:29 +08:00
> 🔔️注意
2023-04-28 00:37:50 +08:00
> Hutool 6.x支持JDK8+对Android平台没有测试不能保证所有工具类或工具方法可用。
2021-01-20 17:10:45 +08:00
2021-04-22 03:30:56 +08:00
### 🚽编译安装
2021-01-20 17:10:45 +08:00
2022-04-28 01:59:51 +08:00
访问Hutool的Gitee主页[https://gitee.com/dromara/hutool](https://gitee.com/dromara/hutool)
2022-04-29 00:32:45 +08:00
下载整个项目源码v6-master或v6-dev分支都可然后进入Hutool项目目录执行
2021-01-20 17:10:45 +08:00
```sh
./hutool.sh install
```
然后就可以使用Maven引入了。
-------------------------------------------------------------------------------
2021-04-20 11:51:29 +08:00
## 🏗️添砖加瓦
2021-01-20 17:10:45 +08:00
2021-04-20 11:51:29 +08:00
### 🎋分支说明
2021-01-20 17:10:45 +08:00
Hutool的源码分为两个分支功能如下
2023-03-13 11:41:20 +08:00
| 分支 | 作用 |
|-----------|--------------------------------------------|
2022-04-29 00:32:45 +08:00
| v6-master | 主分支release版本使用的分支与中央库提交的jar一致不接收任何pr或修改 |
2023-03-13 11:41:20 +08:00
| v6-dev | 开发分支默认为下个版本的SNAPSHOT版本接受修改或pr |
2021-01-20 17:10:45 +08:00
2021-04-20 11:51:29 +08:00
### 🐞提供bug反馈或建议
2021-01-20 17:10:45 +08:00
提交问题反馈请说明正在使用的JDK版本呢、Hutool版本和相关依赖库版本。
2021-03-12 20:58:14 +08:00
- [Gitee issue](https://gitee.com/dromara/hutool/issues)
2021-03-15 11:25:29 +08:00
- [Github issue](https://github.com/dromara/hutool/issues)
2021-01-20 17:10:45 +08:00
2021-04-20 11:51:29 +08:00
### 🧬贡献代码的步骤
2021-01-20 17:10:45 +08:00
1. 在Gitee或者Github上fork项目到自己的repo
2. 把fork过去的项目也就是你的项目clone到你的本地
2022-04-29 00:32:45 +08:00
3. 修改代码记得一定要修改v6-dev分支
4. commit后push到自己的库v6-dev分支
2021-01-20 17:10:45 +08:00
5. 登录Gitee或Github在你首页可以看到一个 pull request 按钮,点击它,填写一些说明信息,然后提交即可。
6. 等待维护者合并
2021-04-20 11:51:29 +08:00
### 📐PR遵照的原则
2021-01-20 17:10:45 +08:00
Hutool欢迎任何人为Hutool添砖加瓦贡献代码不过维护者是一个强迫症患者为了照顾病人需要提交的prpull request符合一些规范规范如下
1. 注释完备尤其每个新增的方法应按照Java文档规范标明方法说明、参数说明、返回值说明等信息必要时请添加单元测试如果愿意也可以加上你的大名。
2. Hutool的缩进按照Eclipse~~不要跟我说IDEA多好用维护者非常懒学不会~~IDEA真香改了Eclipse快捷键后舒服多了默认tab缩进所以请遵守不要和我争执空格与tab的问题这是一个病人的习惯
3. 新加的方法不要使用第三方库的方法Hutool遵循无依赖原则除非在extra模块中加方法工具
2023-04-28 00:37:50 +08:00
4. 请pull request到`v6-dev`分支。Hutool在6.x版本后使用了新的分支`v6-master`是主分支表示已经发布中央库的版本这个分支不允许pr也不允许修改。
### 💞沟通说明
1. 提交地issue或PR未回复并开启状态表示还未处理请耐心等待。
2. 为了保证新issue及时被发现和处理我们会关闭一些描述不足的issue此时你补充说明重新打开即可。
3. PR被关闭表示被拒绝或需要修改地地方较多重新提交即可。
2021-01-20 17:10:45 +08:00
-------------------------------------------------------------------------------
2021-04-20 11:51:29 +08:00
## ⭐Star Hutool
2021-03-12 09:28:37 +08:00
2021-04-13 08:59:25 +08:00
[![Stargazers over time](https://starchart.cc/dromara/hutool.svg)](https://starchart.cc/dromara/hutool)
2023-04-28 00:37:50 +08:00
### GitHub Contributor Over Time
[![Contributor Over Time](https://contributor-overtime-api.git-contributor.com/contributors-svg?chart=contributorOverTime&repo=dromara/hutool)](https://git-contributor.com?chart=contributorOverTime&repo=dromara/hutool)