# wssnail-parent
**Repository Path**: whisperofjune/wssnail-parent
## Basic Information
- **Project Name**: wssnail-parent
- **Description**: Springboot封装常用的组件
1、oss 文件上传
2、redis 封装 分布式锁
3、sms 短信服务
4、leaf 美团id生成器
5、xxl-job xxl-job定时任务 xxl-job中文文档
6、Elasticsearch 工具类
- **Primary Language**: Java
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: https://blog.csdn.net/weixin_39555954
- **GVP Project**: No
## Statistics
- **Stars**: 4
- **Forks**: 3
- **Created**: 2022-07-24
- **Last Updated**: 2025-10-21
## Categories & Tags
**Categories**: Uncategorized
**Tags**: SpringBoot, 组件
## README
# wssnail-parent
#### 介绍
Springboot封装常用的组件
1. oss 文件上传
2. redis 封装 分布式锁
3. sms 短信服务
4. leaf 美团id生成器
5. xxl-job xxl-job定时任务 xxl-job中文文档
6. Elasticsearch 工具类
#### 软件架构
```lua
wssnail-parent #主项目
└──es-spring-boot-starter #elasticsearch
└──leaf-spring-boot-starter #美团leaf id生成
└──leaf-spring-boot-starter-core #美团leaf核心类
└──leaf-spring-boot-starter-server #美团leaf 封装server
└──oss-spring-boot-starter #文件上传
└──redis-spring-boot-starter #redis
└──sms-spring-boot-starter #短信发送
└──wssnail-common #通用模块
└──wssnail-dependencies #组件依赖管理
└──xxl-job-spring-boot-starter #xxl-job
```
#### 安装教程
1. pom中添加依赖
```
com.wssnail
wssnail-dependencies
1.0-SNAPSHOT
pom
import
```
2. oss的使用
```
2.1、添加maven依赖
com.wssnail
oss-spring-boot-starter
2.2 在application.yml中添加配置
wssnail:
oss:
qiniu:
access-key: xxxxx
secret_key: xxxxxx
bucket_name: wssnail-space
temp_path: d://temp #临时文件
domain: http://rh2m5ojho.hn-bkt.clouddn.com/
block-size: 10 #分片的大小MB
url-prefix: http://upload-z2.qiniup.com #上传空间对应的urlprefix
url-prefix说明
/**
* 要上传的空间对应的 urlPrefix scheme + host
* host:
* 华东机房(region0): up.qiniup.com 或 upload.qiniup.com
* 华北机房(region1): up-z1.qiniup.com 或 upload-z1.qiniup.com
* 华南机房(region2): up-z2.qiniup.com 或 upload-z2.qiniup.com
* 北美机房(regionNa0): up-na0.qiniup.com 或 upload-na0.qiniup.com
* 新加坡机房(regionAs0): up-as0.qiniup.com 或 upload-as0.qiniup.com
* 雾存储华东一区(regionFogCnEast1): up-fog-cn-east-1.qiniup.com 或 upload-fog-cn-east-1.qiniup.com
*/
2.3 调用接口
上传文件、删除文件、下载文件、分片上传
```
3. Redis的使用
```
3.1 添加maven依赖
com.wssnail
redis-spring-boot-starter
3.2 分布式锁,该锁不支持重入性,使用时候使用
使用 @SnailRedisLock(lockKey = lockKey, value = value, expireTime = expiretime)
3、3 分项目键值
```
4. sms的使用
```
现阶段只封装了阿里的短信功能
4.1 添加maven依赖
com.wssnail
sms-spring-boot-starter
4.2 在application.yml中添加配置
wssnail:
sms:
aliyun:
accessKeyId: xxxxx
accessKeySecret: xxxx
domain: dysmsapi.aliyuncs.com
regionId: cn-hangzhou
dysmsapi: dysmsapi
signName: 熟透的蜗牛 #短信签名
4.2、 同步发送 和异步发送 ,支持批量发送短信
```
5. leaf的使用
```
5.1 创建数据库,SQL语句在sql文件中
5.2 在实际项目中引入maven依赖
com.wssnail
leaf-spring-boot-starter-server
5.3 添加配置
wssnail:
mt:
leaf:
segment-enable: true
jdbc-username: root
jdbc-password: root
jdbc-url: jdbc:mysql://127.0.0.1:3306/leaf?useUnicode=true&&useSSL=false&characterEncoding=UTF-8&rewriteBatchedStatements=true&allowMultiQueries=true&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
snowflake-enable: false
snowflake-zk-address: 192.168.139.184
snowflake-port: 2181
5.4 使用
long id = segmentService.getId("user").getId();
5.5 存在多数据源的问题,Leaf内部使用的阿里巴巴的Druid数据连接池,测试使用的是Hikari连接池,请注意:如果项目中也使用阿里的Druid连接池的话,可能会有多数据源的问题。
```
6. xxl-job的使用
注意 :本插件支持xxl-job 2.3.1及2.3.1以上版本
```
6.1 创建数据库,SQL语句在sql文件中
6.2 在实际项目中引入maven依赖
com.wssnail
xxl-job-spring-boot-starter
6.3 添加配置
wssnail:
xxl:
job:
admin-addresses: http://127.0.0.1:8080/xxl-job-admin #xxl-job连接地址,必填
log-path: logs/xxl-job #日志文件 非必填
log-retention-days: 10 #日志保留时间 非必填
ip: 127.0.0.1 #执行器的地址,非必填默认是127.0.0.1
port: 9999 #非必填 默认是9999
6.4 使用
@XxlJob("demoJobHandler")
public void demo(){
log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>执行定时任务");
}
具体使用方参考
```
xxl-job项目实战中使用
7. Elasticsearch使用
```
7.1 在实际项目中引入maven依赖
com.wssnail
es-spring-boot-starter
7.2 添加配置
wssnial:
elasticsearch:
hosts: 127.0.0.1:9200 #多个地址用英文下逗号分隔 例如127.0.0.1:9200,127.0.0.2:9200
user-name: snail #如果es设置了密码,必填
password: snail #如果es设置了密码,必填
```
#### 使用说明
1. xxxx
2. xxxx
3. xxxx
#### 参与贡献
1. Fork 本仓库
2. 新建 Feat_xxx 分支
3. 提交代码
4. 新建 Pull Request