feat: 新增heritage-web启动模块
- 新增HeritageApplication主启动类 - 配置所有插件的@Enable注解 - 新增application.yml主配置文件 - 新增application-local.yml本地开发配置 - 新增application-dev.yml开发环境配置 - 配置Logback日志 - 配置OpenAPI文档
This commit is contained in:
parent
f507bdea83
commit
5b4428d39f
105
heritage-web/pom.xml
Normal file
105
heritage-web/pom.xml
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.leocoder.heritage</groupId>
|
||||||
|
<artifactId>heritage-backend</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
|
||||||
|
<name>heritage-web</name>
|
||||||
|
<artifactId>heritage-web</artifactId>
|
||||||
|
<description>入口项目,负责打包</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- SpringBoot Web容器 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- Sa-Token模块和系统管理模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.leocoder.heritage</groupId>
|
||||||
|
<artifactId>heritage-system</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- SpringDoc OpenAPI 3.0 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springdoc</groupId>
|
||||||
|
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- OSS对象存储模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.leocoder.heritage</groupId>
|
||||||
|
<artifactId>heritage-oss</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- 字典管理模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.leocoder.heritage</groupId>
|
||||||
|
<artifactId>heritage-dict</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- 定时任务 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.leocoder.heritage</groupId>
|
||||||
|
<artifactId>heritage-job</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- 代码生成器 -->
|
||||||
|
<!-- <dependency> -->
|
||||||
|
<!-- <groupId>org.leocoder.heritage</groupId> -->
|
||||||
|
<!-- <artifactId>heritage-generator</artifactId> -->
|
||||||
|
<!-- <version>${revision}</version> -->
|
||||||
|
<!-- </dependency> -->
|
||||||
|
<!-- 监控模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.leocoder.heritage</groupId>
|
||||||
|
<artifactId>heritage-monitor</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- 热榜API模块 -->
|
||||||
|
<!-- <dependency> -->
|
||||||
|
<!-- <groupId>org.leocoder.heritage</groupId> -->
|
||||||
|
<!-- <artifactId>coder-hotlist-api</artifactId> -->
|
||||||
|
<!-- <version>${revision}</version> -->
|
||||||
|
<!-- </dependency> -->
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<!-- 指定打包名字 -->
|
||||||
|
<finalName>coder-admin</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>${springboot.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/java</directory>
|
||||||
|
<includes>
|
||||||
|
<include>**/*.xml</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<includes>
|
||||||
|
<include>**/*</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
package org.leocoder.heritage.web;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.leocoder.heritage.desensitize.anno.EnableCoderDesensitize;
|
||||||
|
import org.leocoder.heritage.easyexcel.anno.EnableCoderEasyExcel;
|
||||||
|
import org.leocoder.heritage.limit.anno.EnableCoderLimit;
|
||||||
|
import org.leocoder.heritage.mybatisplus.anno.EnableMybatisPlus;
|
||||||
|
import org.leocoder.heritage.operlog.annotation.EnableOperLog;
|
||||||
|
import org.leocoder.heritage.oss.annotation.EnableCoderOss;
|
||||||
|
import org.leocoder.heritage.repect.anno.EnableCoderRepeatSubmit;
|
||||||
|
import org.leocoder.heritage.resultex.anno.EnableResultEx;
|
||||||
|
import org.leocoder.heritage.satoken.anno.EnableCoderSaToken;
|
||||||
|
import org.leocoder.heritage.dict.anno.EnableCoderDict;
|
||||||
|
import org.leocoder.heritage.job.anno.EnableCoderJob;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : Leocoder
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2025-06-28 14:05
|
||||||
|
* @description : 开头的注解是一个插件插入的开关,如果不是相同目录级别的可以使用这个进行跨包!
|
||||||
|
*/
|
||||||
|
@EnableCoderSaToken
|
||||||
|
@EnableCoderEasyExcel
|
||||||
|
@EnableCoderDesensitize
|
||||||
|
@EnableCoderRepeatSubmit
|
||||||
|
@EnableCoderLimit
|
||||||
|
@EnableMybatisPlus
|
||||||
|
@EnableResultEx
|
||||||
|
@EnableOperLog
|
||||||
|
@EnableCoderOss
|
||||||
|
@EnableCoderDict
|
||||||
|
@EnableCoderJob
|
||||||
|
@EnableScheduling
|
||||||
|
@Slf4j
|
||||||
|
@SpringBootApplication(scanBasePackages = "org.leocoder.heritage")
|
||||||
|
public class HeritageApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// 注意:注入依赖三种选择:@Autowired(required = false) OR @Resource[推荐] OR @RequiredArgsConstructor[推荐]
|
||||||
|
SpringApplication.run(HeritageApplication.class, args);
|
||||||
|
log.info(
|
||||||
|
"\n" +
|
||||||
|
"Coder-Admin管理平台starter =>ヽ(✿゚▽゚)ノ \n" +
|
||||||
|
"超级无敌宇宙最强最帅最可爱系统启动成功(๑‾ ꇴ ‾๑) \n" +
|
||||||
|
" ____ __. .__ _____ ________ _____ .___ _______ \n" +
|
||||||
|
"| |/ _|____ |__| / _ \\ \\______ \\ / \\ | |\\ \\ \n" +
|
||||||
|
"| < / _ \\| | ______ / /_\\ \\ | | \\ / \\ / \\| |/ | \\ \n" +
|
||||||
|
"| | ( <_> ) | /_____/ / | \\| ` \\/ Y \\ / | \\ \n" +
|
||||||
|
"|____|__ \\____/|__| \\____|__ /_______ /\\____|__ /___\\____|__ / \n" +
|
||||||
|
" \\/ \\/ \\/ \\/ \\/ \n" +
|
||||||
|
"CoderApplication[18099] => 闪亮登场(๑•̀ㅂ•́) ✧"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
package org.leocoder.heritage.web.config;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
|
import io.swagger.v3.oas.models.info.Contact;
|
||||||
|
import io.swagger.v3.oas.models.info.Info;
|
||||||
|
import io.swagger.v3.oas.models.info.License;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Leocoder
|
||||||
|
* @description OpenAPI 3.0 配置类
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class OpenApiConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public OpenAPI customOpenAPI() {
|
||||||
|
return new OpenAPI()
|
||||||
|
.info(new Info()
|
||||||
|
.title("Coder-Admin 后台管理系统 API 文档")
|
||||||
|
.description("基于 Spring Boot 3.5.0 的企业级后台管理系统 API 接口文档")
|
||||||
|
.version("1.0.0")
|
||||||
|
.contact(new Contact()
|
||||||
|
.name("Leocoder")
|
||||||
|
.email("admin@leocoder.org")
|
||||||
|
.url("https://www.leocoder.org"))
|
||||||
|
.license(new License()
|
||||||
|
.name("Apache 2.0")
|
||||||
|
.url("https://www.apache.org/licenses/LICENSE-2.0.html")));
|
||||||
|
}
|
||||||
|
}
|
||||||
128
heritage-web/src/main/resources/application-dev.yml
Executable file
128
heritage-web/src/main/resources/application-dev.yml
Executable file
@ -0,0 +1,128 @@
|
|||||||
|
spring:
|
||||||
|
datasource:
|
||||||
|
type: com.zaxxer.hikari.HikariDataSource
|
||||||
|
hikari:
|
||||||
|
# 连接池名字
|
||||||
|
pool-name: HERITAGE-HIKARI-DEV
|
||||||
|
# 最大连接池数量
|
||||||
|
maximum-pool-size: 20
|
||||||
|
# 最小空闲线程数量
|
||||||
|
minimum-idle: 10
|
||||||
|
# 配置获取连接等待超时的时间
|
||||||
|
connectionTimeout: 30000
|
||||||
|
# 校验超时时间
|
||||||
|
validationTimeout: 5000
|
||||||
|
# 空闲连接存活最大时间,默认10分钟
|
||||||
|
idleTimeout: 600000
|
||||||
|
# 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认30分钟
|
||||||
|
maxLifetime: 1800000
|
||||||
|
# 连接测试query[配置检测连接是否有效]
|
||||||
|
connectionTestQuery: SELECT 1
|
||||||
|
# 多久检查一次连接的活性
|
||||||
|
keepaliveTime: 30000
|
||||||
|
dynamic:
|
||||||
|
# 性能分析插件[有性能损耗,不建议生产环境使用]
|
||||||
|
p6spy: true
|
||||||
|
# 默认数据源[master]
|
||||||
|
primary: master
|
||||||
|
# 严格匹配数据源,默认false. true未匹配到指定数据源时抛异常,false使用默认数据源
|
||||||
|
strict: false
|
||||||
|
datasource:
|
||||||
|
# 主库数据源
|
||||||
|
master: # 没有@DS,默认数据源
|
||||||
|
type: ${spring.datasource.type}
|
||||||
|
url: jdbc:mysql://localhost:3306/xxxxxxxx?serverTimezone=GMT%2b8&useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
username: root
|
||||||
|
password: coder
|
||||||
|
# 从库数据源
|
||||||
|
slave: # @DS("dsName"),dsName可以为组名也可以为具体某个库的名称,使用多数据源遵循格式,注解都在mapper层使用。
|
||||||
|
lazy: true
|
||||||
|
type: ${spring.datasource.type}
|
||||||
|
url: jdbc:mysql://localhost:3306/xxxxxxxx?serverTimezone=GMT%2b8&useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
username: root
|
||||||
|
password: coder
|
||||||
|
# redis配置
|
||||||
|
data:
|
||||||
|
redis:
|
||||||
|
# 地址
|
||||||
|
host: localhost
|
||||||
|
# 端口,默认为6379
|
||||||
|
port: 16379
|
||||||
|
# 数据库索引
|
||||||
|
database: 4
|
||||||
|
# 密码[若没有密码请注释掉,若有账号密码:则 账号:密码]
|
||||||
|
password: coder
|
||||||
|
# 连接超时时间
|
||||||
|
timeout: 10s
|
||||||
|
# 是否开启ssl
|
||||||
|
ssl.enabled: false
|
||||||
|
|
||||||
|
# SpringDoc OpenAPI 3.0 配置
|
||||||
|
springdoc:
|
||||||
|
api-docs:
|
||||||
|
# 是否开启 OpenAPI 接口文档
|
||||||
|
enabled: true
|
||||||
|
# OpenAPI 接口文档路径
|
||||||
|
path: /v3/api-docs
|
||||||
|
swagger-ui:
|
||||||
|
# 是否开启 Swagger UI
|
||||||
|
enabled: true
|
||||||
|
# Swagger UI 访问路径
|
||||||
|
path: /swagger-ui.html
|
||||||
|
# 显示 Extensions
|
||||||
|
display-extensions: true
|
||||||
|
# 显示 Common Extensions
|
||||||
|
display-common-extensions: true
|
||||||
|
# 需要扫描的包路径
|
||||||
|
packages-to-scan: org.leocoder.heritage
|
||||||
|
# 接口排序方式[method: 按方法名排序, alpha: 按字母排序]
|
||||||
|
swagger-ui.operations-sorter: method
|
||||||
|
# 标签排序方式[alpha: 按字母排序]
|
||||||
|
swagger-ui.tags-sorter: alpha
|
||||||
|
|
||||||
|
# 项目配置
|
||||||
|
coder:
|
||||||
|
# 名称
|
||||||
|
projectName: HERITAGE-ADMIN
|
||||||
|
# 版本
|
||||||
|
projectVersion: 1.0.0
|
||||||
|
# 文件路径 示例[Windows配置D:/CoderFile,Linux配置 /usr/local/CoderFile]
|
||||||
|
filePath:
|
||||||
|
# 存储服务配置
|
||||||
|
storage:
|
||||||
|
# 存储类型:local(本地存储) | oss(阿里云OSS)
|
||||||
|
type: oss
|
||||||
|
# 阿里云OSS配置
|
||||||
|
oss:
|
||||||
|
# 是否启用OSS存储
|
||||||
|
enabled: true
|
||||||
|
# OSS服务端点
|
||||||
|
endpoint: xxxxxxxx
|
||||||
|
# 访问密钥ID
|
||||||
|
access-key-id: xxxxxxxx
|
||||||
|
# 访问密钥Secret
|
||||||
|
access-key-secret: xxxxxxxx
|
||||||
|
# 存储桶名称
|
||||||
|
bucket-name: xxxxxxxx
|
||||||
|
# 自定义域名(可选)
|
||||||
|
domain: xxxxxxxx
|
||||||
|
# 路径前缀
|
||||||
|
path-prefix: xxxxxxxx
|
||||||
|
# 是否使用HTTPS
|
||||||
|
https: true
|
||||||
|
# 连接超时时间(毫秒)
|
||||||
|
connect-timeout: 10000
|
||||||
|
# 读取超时时间(毫秒)
|
||||||
|
read-timeout: 10000
|
||||||
|
# 全局限流
|
||||||
|
globalLimit:
|
||||||
|
# 是否开启全局限流
|
||||||
|
enabled: false
|
||||||
|
# 默认限流时间[秒]
|
||||||
|
time: 1
|
||||||
|
# 默认限流次数
|
||||||
|
count: 12
|
||||||
|
# 是否封禁IP
|
||||||
|
ban: false
|
||||||
177
heritage-web/src/main/resources/application.yml
Executable file
177
heritage-web/src/main/resources/application.yml
Executable file
@ -0,0 +1,177 @@
|
|||||||
|
server:
|
||||||
|
port: ${port:18099}
|
||||||
|
tomcat:
|
||||||
|
# tomcat的URI编码
|
||||||
|
uri-encoding: UTF-8
|
||||||
|
# Tomcat默认限制文件上传的大小是2MB ,超过就不会被捕获,需要调整大一点或者-1不限制
|
||||||
|
max-swallow-size: -1
|
||||||
|
# 不限制POST提交请求的数据大小,默认是2MB
|
||||||
|
max-http-form-post-size: -1
|
||||||
|
# 连接数满后的排队数,默认为100
|
||||||
|
accept-count: 1000
|
||||||
|
threads:
|
||||||
|
# tomcat最大线程数,默认为200
|
||||||
|
max: 800
|
||||||
|
# Tomcat启动初始化的线程数,默认值10
|
||||||
|
min-spare: 100
|
||||||
|
# 开启GZIP压缩,利于你静态资源传输,提升网站请求响应速度
|
||||||
|
compression:
|
||||||
|
enabled: true
|
||||||
|
min-response-size: 1024
|
||||||
|
# 默认是8k
|
||||||
|
max-http-request-header-size: 80KB
|
||||||
|
spring:
|
||||||
|
messages:
|
||||||
|
encoding: UTF-8
|
||||||
|
basename: i18n/messages
|
||||||
|
profiles:
|
||||||
|
active: local
|
||||||
|
|
||||||
|
# 操作日志配置
|
||||||
|
coder:
|
||||||
|
oper-log:
|
||||||
|
# 异步线程池配置
|
||||||
|
async:
|
||||||
|
core-pool-size: 2
|
||||||
|
max-pool-size: 5
|
||||||
|
queue-capacity: 1000
|
||||||
|
keep-alive-seconds: 60
|
||||||
|
# 日志清理配置
|
||||||
|
clean:
|
||||||
|
enabled: true
|
||||||
|
days: 90
|
||||||
|
cron: "0 0 2 * * ?"
|
||||||
|
# 参数记录配置
|
||||||
|
param:
|
||||||
|
max-length: 2000
|
||||||
|
exclude-fields:
|
||||||
|
- password
|
||||||
|
- pwd
|
||||||
|
- oldPassword
|
||||||
|
- newPassword
|
||||||
|
- confirmPassword
|
||||||
|
# 结果记录配置
|
||||||
|
result:
|
||||||
|
max-length: 2000
|
||||||
|
exclude-large-result: true
|
||||||
|
|
||||||
|
# 解决时间的保存及显示错误问题[实体中就无需再额外注解]
|
||||||
|
jackson:
|
||||||
|
date-format: yyyy-MM-dd HH:mm:ss
|
||||||
|
locale: zh_CN
|
||||||
|
# 解决java中时间是对的,序列化后到前端差8小时
|
||||||
|
time-zone: GMT+8
|
||||||
|
default-property-inclusion: non_null
|
||||||
|
mvc:
|
||||||
|
# 解决时间的保存及显示错误问题[实体中就无需再额外注解]
|
||||||
|
format:
|
||||||
|
date: yyyy-MM-dd HH:mm:ss
|
||||||
|
main: # SpringBootv2.6.3中,做了循环应用的检查,默认情况下,如果类中存在有循环引用的情况,就会报上面的错误
|
||||||
|
allow-circular-references: true
|
||||||
|
application:
|
||||||
|
name: heritage-web
|
||||||
|
servlet:
|
||||||
|
multipart:
|
||||||
|
enabled: true
|
||||||
|
# 是单个文件大小 默认1M
|
||||||
|
max-file-size: 2MB
|
||||||
|
# 是设置总上传的数据大小
|
||||||
|
max-request-size: 10MB
|
||||||
|
freemarker:
|
||||||
|
# 指定HttpServletRequest的属性是否可以覆盖controller的model的同名项
|
||||||
|
allow-request-override: false
|
||||||
|
# req访问request
|
||||||
|
request-context-attribute: request
|
||||||
|
# 后缀名freemarker默认后缀为.ftl,当然你也可以改成自己习惯的.html
|
||||||
|
suffix: .html
|
||||||
|
# 设置响应的内容类型
|
||||||
|
content-type: text/html;charset=utf-8
|
||||||
|
# 是否允许mvc使用freemarker
|
||||||
|
enabled: true
|
||||||
|
# 是否开启template caching
|
||||||
|
cache: false
|
||||||
|
# 检查模板位置是否存在
|
||||||
|
check-template-location: true
|
||||||
|
# 设定模板的加载路径,多个以逗号分隔,默认: [“classpath:/templates/”]
|
||||||
|
template-loader-path: classpath:/templates/,classpath:/templates/**/
|
||||||
|
# 设定Template的编码
|
||||||
|
charset: UTF-8
|
||||||
|
settings:
|
||||||
|
template_update_delay: 0 # 检查模板更新延迟时间,设置为0表示立即检查,如果时间大于0会有缓存不方便进行模板测试
|
||||||
|
tag_syntax: auto_detect
|
||||||
|
default_encoding: UTF-8
|
||||||
|
output_encoding: UTF-8
|
||||||
|
locale: zh_CN
|
||||||
|
date_format: yyyy-MM-dd
|
||||||
|
time_format: HH:mm:ss
|
||||||
|
boolean_format: true,false
|
||||||
|
whitespace_stripping: true
|
||||||
|
url_escaping_charset: UTF-8
|
||||||
|
datetime_format: yyyy/MM/dd HH:mm:ss
|
||||||
|
number_format: 0.##
|
||||||
|
classic_compatible: true
|
||||||
|
# ignore,debug,html_debug,rethrow
|
||||||
|
template_exception_handler: rethrow
|
||||||
|
prefer-file-system-access: false
|
||||||
|
|
||||||
|
# mybatis-plus配置
|
||||||
|
mybatis-plus:
|
||||||
|
mapper-locations: classpath*:mapper/**/*.xml,mapper/*.xml
|
||||||
|
configuration:
|
||||||
|
# MybatisPlus配置中设置将sql日志和结果集输出到控制台,会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
|
# 关闭日志记录[单纯使用 p6spy 分析] org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||||
|
# 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl
|
||||||
|
log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||||
|
global-config:
|
||||||
|
# 是否打印 Logo banner
|
||||||
|
banner: true
|
||||||
|
dbConfig:
|
||||||
|
# 主键类型
|
||||||
|
# AUTO[自增] NONE[空] INPUT[用户输入] ASSIGN_ID[雪花] ASSIGN_UUID[唯一] UUID[UUID]
|
||||||
|
idType: ASSIGN_ID
|
||||||
|
# 逻辑已删除值[框架表均使用此值 禁止随意修改]
|
||||||
|
logicDeleteValue: 0
|
||||||
|
# 逻辑未删除值
|
||||||
|
logicNotDeleteValue: 1
|
||||||
|
insertStrategy: NOT_NULL
|
||||||
|
updateStrategy: NOT_NULL
|
||||||
|
whereStrategy: NOT_NULL
|
||||||
|
############## Sa-Token 配置 [文档: https://sa-token.cc] ##############
|
||||||
|
# 1、被顶下线旧的token为何还存在? 如果还是用旧token来请求,就会返回你已被顶下线
|
||||||
|
# 2、前后端分离模式记录的sa-session存在哪个地方? 会存在Redis中
|
||||||
|
# 3、前后端分离模式,退出时,前后端模式获取到token的值只从前端传递过来headers中拿(yml中进行配置的,如下方所示)
|
||||||
|
# 然后StpUtil.logout();自动根据Headers的Authorization获取值,进行从redis中删除token
|
||||||
|
# 是否尝试从header里读取token,Header用来获取客户端使用的操作系统和浏览器名称和版本和token,前端将token怎么存储的需要跟yml下方中配置的保持一致
|
||||||
|
# is-read-header: true
|
||||||
|
# 是否尝试从cookie里读取token
|
||||||
|
# is-read-cookie: false
|
||||||
|
# 是否尝试从请求体里读取token
|
||||||
|
# is-read-body: false
|
||||||
|
# StpUtil.getLoginIdAsString() 使用这种Sa-Token封装的方法必须携带token
|
||||||
|
sa-token:
|
||||||
|
# token名称 [同时也是cookie名称,推荐使用]
|
||||||
|
token-name: Authorization
|
||||||
|
# token 前缀
|
||||||
|
token-prefix: Bearer
|
||||||
|
# token 风格(默认可取值:uuid、simple-uuid、random-32、random-64、random-128、tik)
|
||||||
|
token-style: tik
|
||||||
|
# token有效期,单位s 默认30天, -1代表永不过期(10800[3小时]后端生成的 token,即使用户一直操作,在 30 天后一定会过期,要求用户重新登录)
|
||||||
|
timeout: -1
|
||||||
|
# token 最低活跃频率[单位:秒],如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结 3600
|
||||||
|
active-timeout: -1
|
||||||
|
# 自动续签,指定时间内有操作,则会自动续签
|
||||||
|
auto-renew: true
|
||||||
|
# 是否尝试从cookie里读取token
|
||||||
|
is-read-cookie: false
|
||||||
|
# 是否尝试从header里读取token
|
||||||
|
is-read-header: true
|
||||||
|
# 是否允许同一账号多地同时登录[为 true 时允许一起登录, 为 false 时新登录挤掉旧登录]
|
||||||
|
is-concurrent: true
|
||||||
|
# 在多人登录同一账号时,是否共用一个 token[为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token]
|
||||||
|
is-share: false
|
||||||
|
# 是否在初始化配置时打印版本字符画
|
||||||
|
is-print: true
|
||||||
|
# 是否输出操作日志
|
||||||
|
is-log: true
|
||||||
|
|
||||||
|
|
||||||
67
heritage-web/src/main/resources/logback-spring-hour.xml
Executable file
67
heritage-web/src/main/resources/logback-spring-hour.xml
Executable file
@ -0,0 +1,67 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- 注意:此日志配置将info、warn、error日志合并一个输出,并且按照小时自动生成。 -->
|
||||||
|
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||||
|
<contextName>heritage-logback</contextName>
|
||||||
|
|
||||||
|
<property name="HERITAGE_ADMIN_LOGS" value="./logs"/>
|
||||||
|
|
||||||
|
<!-- 彩色日志 -->
|
||||||
|
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
|
||||||
|
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
|
||||||
|
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
|
||||||
|
<!-- 彩色日志格式 [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n -->
|
||||||
|
<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr([TraceId: %X{traceId}]%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
||||||
|
|
||||||
|
<!-- 控制台 -->
|
||||||
|
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="combinedFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||||
|
<level>INFO</level>
|
||||||
|
</filter>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>ERROR</level>
|
||||||
|
</filter>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>WARN</level>
|
||||||
|
</filter>
|
||||||
|
<!-- 日志存储路径 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<fileNamePattern>${HERITAGE_ADMIN_LOGS}/%d{yyyy-MM-dd_HH}.log</fileNamePattern>
|
||||||
|
<maxHistory>30</maxHistory>
|
||||||
|
<!-- 每个小时生成一个新的文件,而不受日志大小限制(比如100MB)的影响,可以将这个注释 -->
|
||||||
|
<!-- 单个日志文件最大100M,到了这个值,就会再创建一个日志文件,日志文件的名字最后+1 -->
|
||||||
|
<!-- <maxFileSize>100MB</maxFileSize> -->
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
<pattern>[[TraceId: %X{traceId}]%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] %-5level %logger{36} : %msg%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<springProfile name="local">
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="stdout"/>
|
||||||
|
<appender-ref ref="combinedFile"/>
|
||||||
|
</root>
|
||||||
|
</springProfile>
|
||||||
|
|
||||||
|
<springProfile name="dev">
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="stdout"/>
|
||||||
|
<appender-ref ref="combinedFile"/>
|
||||||
|
</root>
|
||||||
|
</springProfile>
|
||||||
|
|
||||||
|
<springProfile name="prod">
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="combinedFile"/>
|
||||||
|
</root>
|
||||||
|
</springProfile>
|
||||||
|
|
||||||
|
</configuration>
|
||||||
109
heritage-web/src/main/resources/logback-spring-part.xml
Executable file
109
heritage-web/src/main/resources/logback-spring-part.xml
Executable file
@ -0,0 +1,109 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- 注意:此日志配置将info、error日志分开输出,并且按照小时生成,日志文件不足100MB则还打印到第一个生成的日志文件。 -->
|
||||||
|
<!--
|
||||||
|
scan: 当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true。
|
||||||
|
scanPeriod: 设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。
|
||||||
|
debug: 当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。
|
||||||
|
configuration 子节点为 appender、logger、root
|
||||||
|
注意:此日志配置是将info、error日志分开放置。
|
||||||
|
-->
|
||||||
|
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||||
|
<!-- 用于区分不同应用程序的记录 -->
|
||||||
|
<contextName>heritage-logback</contextName>
|
||||||
|
|
||||||
|
<!-- 日志文件所在目录,如果是tomcat,如下写法日志文件会在则为${TOMCAT_HOME}/bin/logs/目录下 -->
|
||||||
|
<property name="HERITAGE_ADMIN_LOGS" value="./logs"/>
|
||||||
|
<!-- 彩色日志 -->
|
||||||
|
<!-- 彩色日志依赖的渲染类 -->
|
||||||
|
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
|
||||||
|
<conversionRule conversionWord="wex"
|
||||||
|
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
|
||||||
|
<conversionRule conversionWord="wEx"
|
||||||
|
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
|
||||||
|
<!-- 彩色日志格式 [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n -->
|
||||||
|
<property name="CONSOLE_LOG_PATTERN"
|
||||||
|
value="${CONSOLE_LOG_PATTERN:-%clr([TraceId: %X{traceId}]%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
||||||
|
|
||||||
|
<!-- 控制台 -->
|
||||||
|
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<!-- 格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度 %logger输出日志的logger名 %msg:日志消息,%n是换行符 -->
|
||||||
|
<!-- <pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] %-5level %logger{36} : %msg%n</pattern> -->
|
||||||
|
<pattern>${CONSOLE_LOG_PATTERN}</pattern><!-- 彩打日志 -->
|
||||||
|
<!-- 解决乱码问题 -->
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 滚动文件 -->
|
||||||
|
<appender name="infoFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<!-- ThresholdFilter:临界值过滤器,过滤掉 TRACE 和 DEBUG 级别的日志 -->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||||
|
<level>INFO</level>
|
||||||
|
</filter>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<fileNamePattern>${HERITAGE_ADMIN_LOGS}/info/%d{yyyy-MM-dd}/%d{HH}.log</fileNamePattern>
|
||||||
|
<!-- 每个小时生成一个新的文件,而不受日志大小限制(比如100MB)的影响,可以将这个注释 -->
|
||||||
|
<!-- 单个日志文件最大100M,到了这个值,就会再创建一个日志文件,日志文件的名字最后+1 -->
|
||||||
|
<maxFileSize>100MB</maxFileSize>
|
||||||
|
<!-- 保存最近30天的日志 -->
|
||||||
|
<maxHistory>30</maxHistory>
|
||||||
|
<!-- 所有的日志文件最大3G,超过就会删除旧的日志 -->
|
||||||
|
<totalSizeCap>10GB</totalSizeCap>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
<pattern>[[TraceId: %X{traceId}]%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] %-5level %logger{36} : %msg%n
|
||||||
|
</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 滚动文件 -->
|
||||||
|
<appender name="errorFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<!-- ThresholdFilter:临界值过滤器,过滤掉 TRACE 和 DEBUG 级别的日志 -->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||||
|
<level>ERROR</level>
|
||||||
|
</filter>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<fileNamePattern>${HERITAGE_ADMIN_LOGS}/error/%d{yyyy-MM-dd}/%d{HH}.log</fileNamePattern>
|
||||||
|
<!-- 每个小时生成一个新的文件,而不受日志大小限制(比如100MB)的影响,可以将这个注释 -->
|
||||||
|
<!-- 单个日志文件最大100M,到了这个值,就会再创建一个日志文件,日志文件的名字最后+1 -->
|
||||||
|
<maxFileSize>100MB</maxFileSize>
|
||||||
|
<!-- 保存最近30天的日志 -->
|
||||||
|
<maxHistory>30</maxHistory>
|
||||||
|
<!-- 所有的日志文件最大3G,超过就会删除旧的日志 -->
|
||||||
|
<totalSizeCap>10GB</totalSizeCap>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
<pattern>[[TraceId: %X{traceId}]%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] %-5level %logger{36} : %msg%n
|
||||||
|
</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 配置多环境日志输出 可以在application.properties中配置选择哪个profiles : spring.profiles.active=dev -->
|
||||||
|
<!-- 开发环境:打印控制台 -->
|
||||||
|
|
||||||
|
<springProfile name="local">
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="stdout"/>
|
||||||
|
<appender-ref ref="combinedFile"/>
|
||||||
|
</root>
|
||||||
|
</springProfile>
|
||||||
|
|
||||||
|
<springProfile name="dev">
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="stdout"/>
|
||||||
|
<appender-ref ref="infoFile"/>
|
||||||
|
<appender-ref ref="errorFile"/>
|
||||||
|
</root>
|
||||||
|
</springProfile>
|
||||||
|
<!-- 生产环境:输出到文件 -->
|
||||||
|
<springProfile name="prod">
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="infoFile"/>
|
||||||
|
<appender-ref ref="errorFile"/>
|
||||||
|
</root>
|
||||||
|
</springProfile>
|
||||||
|
|
||||||
|
</configuration>
|
||||||
71
heritage-web/src/main/resources/logback-spring.xml
Executable file
71
heritage-web/src/main/resources/logback-spring.xml
Executable file
@ -0,0 +1,71 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- 注意:此日志配置将info、warn、error日志合并一个输出,按照天划分,大于100MB后面日志名字最后+1 -->
|
||||||
|
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||||
|
<contextName>heritage-logback</contextName>
|
||||||
|
|
||||||
|
<property name="HERITAGE_ADMIN_LOGS" value="./logs"/>
|
||||||
|
|
||||||
|
<!-- 彩色日志 -->
|
||||||
|
<conversionRule conversionWord="clr" class="org.springframework.boot.logging.logback.ColorConverter"/>
|
||||||
|
<conversionRule conversionWord="wex" class="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
|
||||||
|
<conversionRule conversionWord="wEx" class="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
|
||||||
|
<!-- 彩色日志格式 [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n -->
|
||||||
|
<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr([TraceId: [%boldCyan(%X{traceId})]]%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
||||||
|
|
||||||
|
<!-- 控制台 -->
|
||||||
|
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="combinedFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||||
|
<level>INFO</level>
|
||||||
|
</filter>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>ERROR</level>
|
||||||
|
</filter>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>WARN</level>
|
||||||
|
</filter>
|
||||||
|
<!-- 日志存储路径 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<fileNamePattern>${HERITAGE_ADMIN_LOGS}/%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<maxHistory>30</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<!-- 日志很多每天,需要拆分使用下方这个 -->
|
||||||
|
<!-- <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">-->
|
||||||
|
<!-- <fileNamePattern>${HERITAGE_ADMIN_LOGS}/%d{yyyy-MM-dd}.%i.log</fileNamePattern>-->
|
||||||
|
<!-- <maxHistory>30</maxHistory>-->
|
||||||
|
<!-- <!– 单个日志文件最大100M –>-->
|
||||||
|
<!-- <maxFileSize>100MB</maxFileSize>-->
|
||||||
|
<!-- </rollingPolicy>-->
|
||||||
|
<encoder>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
<pattern>[[TraceId: %X{traceId}]%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] %-5level %logger{36} : %msg%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<springProfile name="local">
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="stdout"/>
|
||||||
|
<appender-ref ref="combinedFile"/>
|
||||||
|
</root>
|
||||||
|
</springProfile>
|
||||||
|
|
||||||
|
<springProfile name="dev">
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="stdout"/>
|
||||||
|
<appender-ref ref="combinedFile"/>
|
||||||
|
</root>
|
||||||
|
</springProfile>
|
||||||
|
|
||||||
|
<springProfile name="prod">
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="combinedFile"/>
|
||||||
|
</root>
|
||||||
|
</springProfile>
|
||||||
|
|
||||||
|
</configuration>
|
||||||
Loading…
Reference in New Issue
Block a user