Appearance
快速开始
依赖引用
在您的Spring Boot项目的pom.xml
中添加以下依赖
Spring Boot 2(java8)
xml
<dependency>
<groupId>io.github.liyao52033</groupId>
<artifactId>common-spring-boot-starter</artifactId>
<version>1.2.4</version>
</dependency>
<dependency>
<groupId>io.github.liyao52033</groupId>
<artifactId>ErrorCode-spring-boot-starter</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>com.hccake</groupId>
<artifactId>ballcat-spring-boot-starter-easyexcel</artifactId>
<version>1.4.1</version>
</dependency>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Spring Boot 3(java17)
xml
<dependency>
<groupId>io.github.liyao52033</groupId>
<artifactId>liyao-spring-boot3-starter-common</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>io.github.liyao52033</groupId>
<artifactId>liyao-spring-boot3-starter-ErrorCode</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>io.github.liyao52033</groupId>
<artifactId>liyao-spring-boot-starter-fastexcel</artifactId>
<version>1.2.0</version>
</dependency>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
yml配置
cos对象存储
可参考官方文档开通cos,然后在访问管理控制台找到下面accessKey
与secretKey
,在控制台找到region
与bucket
,在自定义源站域名将自己的域名与源站关联,用于访问和管理网站或应用的内容。您可将已备案的自定义域名绑定到存储桶,通过自定义源站域名访问存储桶内的对象
警告
enabled是Spring Boot 3版本特有,Spring Boot 2版本只要引入此依赖就会自动装配,需提前在yml配置好相关参数,不然启动会报错
yml
# 腾讯云cos对象存储
liyao:
cos:
enabled: true
accessKey: # 身份识别ID,可在腾讯云API密钥管理页面获取
secretKey: # 身份密钥, 可在腾讯云API密钥管理页面获取
region: # 地域信息
bucket: # 存储桶名称
domain: # 自定义源站域名,格式为https://example.com
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
验证码
警告
Spring Boot 3不支持ARITHMETIC
算术类型
可选类型如下
ARITHMETIC
算术类型CHINESE
中文类型CHINESE_GIF
中文gif类型GIF
gif类型SPEC
png类型
yml
# 验证码
liyao:
captcha:
# 验证码类型
type: SPEC
#过期时间
ttl: 180
1
2
3
4
5
6
7
2
3
4
5
6
7
Redis配置
本starter已经预配置了RedisTemplate,使用JSON序列化,可以直接注入使用
java
@Resource
private RedisTemplate<String, Object> redisTemplate;
// 使用示例
redisTemplate.opsForValue().set("key", value);
1
2
3
4
5
2
3
4
5
限流器
yaml
liyao:
system:
rate-limiter-count: 10 # 同一IP每秒最多请求次数
1
2
3
2
3
代码生成
需提前在resource/templates
下准备freemaker
模板文件,将下面信息填好后可快速生成crud
yml
# 代码生成
liyao:
generator:
#是否开启代码生成器
enabled: false
# 生成的包名
package-name: com.starter.springbootInit
# 为模板文件提供的实体类
input-file: com.starter.springbootInit.model.entity.Excel
data-name: excel
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
license授权
使用 keytool 生成公私钥证书库
例如:私钥库密码为 private123456,公钥库密码为 public123456,生成步骤如下:
bash
# 1. 生成私钥库
# validity:私钥的有效期(天)
# alias:私钥别称
# keystore:私钥库文件名称(生成在当前目录)
# storepass:私钥库密码(获取 keystore 信息所需的密码,密钥库口令)
# keypass:别名条目的密码(密钥口令)
keytool -genkeypair -keysize 1024 -validity 3650 -alias "privateKey" -keystore "privateKeys.keystore" -storepass "public123456" -keypass "private123456" -dname "CN=localhost, OU=localhost, O=localhost, L=SH, ST=SH, C=CN"
# 2. 把私钥库内的公钥导出到一个文件当中
# alias:私钥别称
# keystore:私钥库的名称(在当前目录查找)
# storepass:私钥库的密码
# file:证书名称
keytool -exportcert -alias "privateKey" -keystore "privateKeys.keystore" -storepass "pubwd123456" -file "certfile.cer"
# 3.再把这个证书文件导入到公钥库,certfile.cer 没用了可以删掉了
# alias:公钥名称
# file:证书名称
# keystore:公钥文件名称
# storepass:公钥库密码
keytool -import -alias "publicCert" -file "certfile.cer" -keystore "publicCerts.keystore" -storepass "public123456"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
更多配置请查看TrueLicense官方文档
完整yml
yml
liyao:
# 腾讯云cos对象存储
cos:
accessKey: # 身份识别ID,可在腾讯云API密钥管理页面获取
secretKey: # 身份密钥, 可在腾讯云API密钥管理页面获取
region: # 地域信息
bucket: # 存储桶名称格式
domain: # 自定义域名
# 验证码
captcha:
# 验证码类型
type: ARITHMETIC
#过期时间
ttl: 180
# 代码生成
generator:
#是否开启代码生成器
enabled: false
# 生成的包名
package-name: com.starter.springbootInit
# 模板文件位置
input-file: com.starter.springbootInit.model.entity.Excel
data-name: excel
# 是否开启接口日志
log:
enabled: true
# 限流器
system:
rate-limiter-count: 10 # 限流次数
# license授权
license:
# 是否开启接口授权
enabled: true
# 主题
subject: starter
# 公钥别称
publicAlias:
# 访问公钥的密码
publicKeystorePass:
# license授权文件位置
licensePath:
# 公钥所在的位置
publicKeysStorePath:
# 将license授权文件上传的位置
uploadPath:
# 排除授权验证的接口
allowed-paths:
- /api/license/getServerInfos #获取服务器硬件信息
- /api/license/generateLicense #生成授权文件
- /api/license/uploadLicense #上传授权文件
- /api/captcha/get #生成验证码
- /api/captcha/check #验证验证码
- /api/user/login #登录
- /api/user/register #注册
- /api/user/getInfo # 获取当前登录用户
- /api/user/logout # 退出登录
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61