common-api模块【application.yml文件】
project:version: @来自顶级pom.xml的properties配置@
---
spring:profiles:# 根据当前活跃环境指定对应的 application文件active: @profiles.active@
---
spring:datasource:driver-class-name: com.p6spy.engine.spy.P6SpyDriverurl: jdbc:p6spy:mysql://localhost:3306/你的数据库?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true&generateSimpleParameterMetadata=true&nullCatalogMeansCurrent=trueusername: 你的账号password: 你的密码type: com.alibaba.druid.pool.DruidDataSourcedruid:# 初始连接数initial-size: 5# 最小连接池数量min-idle: 5# 最大连接池数量max-active: 20# 配置检测连接是否有效validation-query: SELECT 1 FROM DUALtest-while-idle: truetest-on-borrow: falsetest-on-return: false# 打开PSCache,并且指定每个连接上PSCache的大小pool-prepared-statements: true# 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙max-pool-prepared-statement-per-connection-size: 20filter:stat:enabled: truelog-slow-sql: trueslow-sql-millis: 2000merge-sql: truewall:config:multi-statement-allow: trueuse-global-data-source-stat: true# 通过connectProperties属性来打开mergeSql功能;慢SQL记录connect-properties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000# 配置监控服务器stat-view-servlet:enabled: truelogin-username: druid账号login-password: druid密码reset-enable: falseurl-pattern: /druid/*# 设置白名单,不填则允许所有访问allow: localhostweb-stat-filter:# 添加过滤规则url-pattern: /*# 忽略过滤格式exclusions: "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"
---
spring:data:redis:repositories:enabled: false
---
spring:mvc:pathmatch:matching-strategy: PATH_PATTERN_PARSER
---
spring:servlet:multipart:# 单个文件大小max-file-size: 10MB# 所有文件上传总大小max-request-size: 100MB
---
spring:redis:host: 127.0.0.1port: 6379lettuce:pool:# 最大活动数量max-active: 8# 当池耗尽时,在引发异常之前,连接分配应该阻塞的最长时间。使用负值可以无限期阻止。max-wait: -1# 最大闲置时间,单位:smax-idle: 500# 超时关闭时间shutdown-timeout: 0
---
spring:jpa:database: MYSQLdatabase-platform: org.hibernate.dialect.MySQL8Dialect# 有p6spy了就可以不用你了show-sql: falseopen-in-view: truehibernate:ddl-auto: updategenerate_statistics: truenaming:physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImplproperties:hibernate:jdbc:# 批量保存时重写SQL语句,每批1000条提交batch_size: 1000batch_versioned_data: trueorder_inserts: trueorder_updates: true# 定义JPA的SQL拦截,没有需要可以不创建
# session_factory:
# statement_inspector: com.freesia.interceptor.JpaDataPermissionInterceptor
# Mybatis
mybatis-plus:mapper-locations: classpath*:/mapper/*.xmlconfiguration:log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpllazy-loading-enabled: true# 启动时是否检查 MyBatis XML 文件的存在,默认不检查checkConfigLocation: falseglobal-config:banner: falseworker-id: ${random.int(1,31)}datacenter-id: ${random.int(1,31)}db-config:id-type: ASSIGN_ID
# 日志相关
logging:config: classpath:logback-spring.xmllevel:root: INFO
# spring安全信息
management:endpoints:enabled-by-default: trueweb:exposure:include: 'health'endpoint:health:enabled: trueshow-details: always
common-api模块 国际化i18n文件【messages_common.properties】
common-api -> resources -> 创建i18n文件夹并创建三个messages_common.properties文件
日志监控p6spy【spy.properteis】
# p6spy 性能分析插件配置文件
modulelist=com.baomidou.mybatisplus.extension.p6spy.MybatisPlusLogFactory,com.p6spy.engine.outage.P6OutageFactory
# 自定义日志打印
logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger
#日志输出到控制台
#appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger
#日志输出到日志文件
# 使用日志系统记录 sql
appender=com.p6spy.engine.spy.appender.Slf4JLogger
# 设置 p6spy driver 代理
#deregisterdrivers=true
# 取消JDBC URL前缀
useprefix=true
# 配置记录 Log 例外,可去掉的结果集有error,info,batch,debug,statement,commit,rollback,ok,resultset.
excludecategories=info,debug,result,commit,resultset
# 日期格式
dateformat=yyyy-MM-dd HH:mm:ss
# SQL语句打印时间格式
databaseDialectTimestampFormat=yyyy-MM-dd HH:mm:ss
# 实际驱动可多个
#driverlist=org.h2.Driver
# 是否开启慢SQL记录
outagedetection=true
# 慢SQL记录标准 2 秒
outagedetectioninterval=2
# 是否过滤 Log
filter=true
# 过滤 Log 时所排除的 sql 关键字,以逗号分隔
exclude=SELECT 1
日志处理配置【logback-spring.xml】
<configuration debug="false" scan="true" scanPeriod="10 seconds"><include resource="org/springframework/boot/logging/logback/defaults.xml"/><contextName>logback</contextName><!--输出sql语句--><logger name="com.freesia" level="INFO"/><property name="log.path" value="./logs/"/><property name="maxHistory" value="7"/><property name="maxFileSize" value="50MB"/><property name="consolePattern"value="%red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}) %yellow([%file : %line]%n) * %msg%n"/><property name="logPattern" value="%date %level [%thread] %logger{36} [%file : %line] %msg%n"/><springProperty name="springName" source="spring.application.name" defaultValue="freesia-default"/><appender name="console" class="ch.qos.logback.core.ConsoleAppender"><filter class="ch.qos.logback.classic.filter.ThresholdFilter"><level>INFO</level></filter><encoder><pattern>${consolePattern}</pattern><charset>utf-8</charset></encoder></appender><appender name="info_file" class="ch.qos.logback.core.rolling.RollingFileAppender"><file>${log.path}/info.log</file><rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"><!-- 每天一归档 --><fileNamePattern>${log.path}/zip/logback_info.log.%d{yyyy-MM-dd}-%i.zip</fileNamePattern><maxHistory>${maxHistory}</maxHistory><timeBasedFileNamingAndTriggeringPolicyclass="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"><maxFileSize>${maxFileSize}</maxFileSize></timeBasedFileNamingAndTriggeringPolicy></rollingPolicy><encoder><pattern>${logPattern}</pattern></encoder><filter class="ch.qos.logback.classic.filter.LevelFilter"><level>INFO</level><onMatch>ACCEPT</onMatch><onMismatch>DENY</onMismatch></filter></appender><appender name="warn_file" class="ch.qos.logback.core.rolling.RollingFileAppender"><file>${log.path}/warn.log</file><rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"><!-- 每天一归档 --><fileNamePattern>${log.path}//zip/logback_warn.log.%d{yyyy-MM-dd}-%i.zip</fileNamePattern><maxHistory>${maxHistory}</maxHistory><timeBasedFileNamingAndTriggeringPolicyclass="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"><maxFileSize>${maxFileSize}</maxFileSize></timeBasedFileNamingAndTriggeringPolicy></rollingPolicy><encoder><pattern>${logPattern}</pattern></encoder><filter class="ch.qos.logback.classic.filter.LevelFilter"><level>WARN</level><onMatch>ACCEPT</onMatch><onMismatch>DENY</onMismatch></filter></appender><appender name="error_file" class="ch.qos.logback.core.rolling.RollingFileAppender"><file>${log.path}/error.log</file><rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"><!-- 每天一归档 --><fileNamePattern>${log.path}//zip/logback_error.log.%d{yyyy-MM-dd}-%i.zip</fileNamePattern><maxHistory>${maxHistory}</maxHistory><timeBasedFileNamingAndTriggeringPolicyclass="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"><maxFileSize>${maxFileSize}</maxFileSize></timeBasedFileNamingAndTriggeringPolicy></rollingPolicy><encoder><pattern>${logPattern}</pattern></encoder><filter class="ch.qos.logback.classic.filter.LevelFilter"><level>ERROR</level><onMatch>ACCEPT</onMatch><onMismatch>DENY</onMismatch></filter></appender><root><level value="info"/><appender-ref ref="console"/><appender-ref ref="info_file"/><appender-ref ref="warn_file"/><appender-ref ref="error_file"/></root></configuration>
web-app模块【application-dev.yml配置文件】
server:port: 8570
---
spring:application:name: freesia-admin
---
freesia:web:common:# 是否初始化系统配置init-sys-config: true# 是否初始化数据字典init-sys-dict: truetenant:enabled: truetenant-column: TENANT_IDignore-table: SYS_TENANT,SYS_USER,SYS_MENU,SYS_DEPT,SYS_ROLE,SYS_ROLE_MENU,SYS_ROLE_DEPT,SYS_TENANT_USER,SYS_USER_ROLE,SYS_DICT_KEY,SYS_DICT_VALUE,URL_CONFIG,SYS_CONFIG,SYS_OSS,SYS_OSS_CONFIG
---
login.password:# 密码最大错误次数maxRetryCount: 5# 密码锁定时间(默认10分钟 Duration)lockTime: 10M
---
# 生成验证码
captcha:type: CALCULATEstrategy: CIRCLEnumberLength: 1charLength: 4
---
spring:messages:# 引入不同模块的i18n messages文件,逗号分隔 basename: i18n/messages_common,i18n/messagesencoding: UTF-8
---
# Sa-Token配置
sa-token:# 打印日志is-log: false# 打印彩色日志is-color-log: false# 启动不打印banneris-print: false# token名称 (同时也是cookie名称)token-name: Authorization# token有效期 设为一天 (必定过期) 单位: 秒timeout: 86400# 多端不同 token 有效期 可查看 USecurity.loginByDevice 方法自定义# token最低活跃时间 (指定时间无操作就过期) 单位: 秒active-timeout: 43200# 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)is-concurrent: true# 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)is-share: true# 是否尝试从header里读取tokenis-read-header: true# 是否尝试从cookie里读取tokenis-read-cookie: false# token前缀token-prefix: "Bearer"# jwt秘钥jwt-secret-key: DoYouLikeWhatYouSee?
---
# security配置
security:# 排除路径excludes:# 静态资源- /*.html- /**/*.html- /**/*.css- /**/*.js# 公共路径- /favicon.ico- /error# swagger 文档配置- /*/api-docs- /*/api-docs/**# actuator 监控配置- /actuator- /actuator/**
---
# 接口文档
springdoc:api-docs:enabled: trueswagger-ui:path: /swagger-ui.html# 添加该属性才能在刷新或重新打开标签时不会重置auth值persist-authorization: trueinfo:title: 接口文档的标题decription: 接口文档的描述license:name: APACHE LICENSE VERSION 2.0url: https://www.apache.org/licenses/LICENSE-2.0.htmlversion: '版本号: ${project.version}'termsOfService: 'http://localhost:${server.port}}'contact:name: Evad Devilvanemail: evaddevilvan@outlook.comurl: https://gitee.com/devilvan/freesiaexternalDocs:description: Git仓库地址url: https://gitee.com/devilvan/freesiacomponents:# 鉴权方式配置security-schemes:apiKey:type: APIKEYin: HEADERname: ${sa-token.token-name}tenantId:type: APIKEYin: HEADERname: X-Tenent-Idgroup-configs:- group: 01. 登录、注册模块paths-to-match:- /api/sysLoginController/**- /api/sysRegistryController/**- group: 02. 用户模块paths-to-match: /api/sysUserController/**- group: 03. 角色模块paths-to-match: /api/sysRoleController/**- group: 04. 菜单模块paths-to-match: /api/sysMenuController/**- group: 05. 部门模块paths-to-match: /api/sysDeptController/**- group: 06. 字典模块paths-to-match: /api/sysDictController/**- group: 07. 操作日志模块paths-to-match: /api/sysSensitiveLogController/**- group: 08. 数据面板模块paths-to-match: /dashboard/**- group: 09. 基础服务模块paths-to-match: /common/**- group: 10. 租户模块paths-to-match: /api/sysTenantController/**
# knife4j的增强配置,不需要增强可以不配
#knife4j:
# enable: true
# setting:
# language: zh_cn
web-api模块 国际化i18n文件【messages.properties】
web-api -> resources -> 创建i18n文件夹并创建三个messages.properties文件
Spring启动时的banner图案【banner.txt】
图案生成网址: http://www.network-science.de/ascii/