Skip to content

Commit

Permalink
👔 增加配置文件注释,简化配置文件
Browse files Browse the repository at this point in the history
  • Loading branch information
lltx committed Apr 18, 2024
1 parent c629c6a commit dc985eb
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 50 deletions.
12 changes: 8 additions & 4 deletions pig-boot/src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
spring:
cache:
type: redis # 缓存类型 Redis
data:
redis:
host: pig-redis
host: pig-redis # Redis地址
password: # Redis密码,没有留空
port: 6379 # Redis端口
# 数据库相关配置
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
Expand All @@ -26,9 +30,9 @@ security:
# 配置文件加密根密码
jasypt:
encryptor:
password: pig
algorithm: PBEWithMD5AndDES
iv-generator-classname: org.jasypt.iv.NoIvGenerator
password: pig # 加密根密码
algorithm: PBEWithMD5AndDES # 加密算法
iv-generator-classname: org.jasypt.iv.NoIvGenerator # 无向量生成器

# swagger 配置
swagger:
Expand Down
65 changes: 19 additions & 46 deletions pig-boot/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,29 @@
server:
port: 9999
port: 9999 # 项目端口
servlet:
context-path: /admin
context-path: /admin # 项目访问路径

spring:
application:
name: @project.artifactId@
# 缓存相关配置
cache:
type: redis
# 定时任务属性配置
quartz:
properties:
org:
quartz:
scheduler:
instanceName: clusteredScheduler
instanceId: AUTO
jobStore:
class: org.springframework.scheduling.quartz.LocalDataSourceJobStore
driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate
tablePrefix: QRTZ_
isClustered: true
clusterCheckinInterval: 10000
useProperties: false
threadPool:
class: org.quartz.simpl.SimpleThreadPool
threadCount: 50
threadPriority: 5
threadsInheritContextClassLoaderOfInitializingThread: true
job-store-type: jdbc
jdbc:
initialize-schema: always # 生产注意设置为 never
startup-delay: 10
name: @project.artifactId@ # 服务名称,取 pom.xml 中的 artifactId
# 上传文件大小限制
servlet:
multipart:
max-file-size: 100MB
max-request-size: 100MB
max-file-size: 100MB # 单个文件最大
max-request-size: 100MB # 接收的最大请求大小
cloud:
nacos:
nacos: # 单机版本关闭nacos 服务发现和配置管理的能力
config:
enabled: false
discovery:
enabled: false
main:
allow-bean-definition-overriding: true
allow-bean-definition-overriding: true # 允许覆盖bean定义
profiles:
active: dev
active: dev # 激活dev,对应 application-dev.yml


## spring security 对外暴露接口设置
## spring security 对外暴露接口设置(不鉴权直接可访问)
security:
micro: false
oauth2:
Expand All @@ -71,16 +44,16 @@ security:
#--------------如下配置尽量不要变动-------------
# mybatis-plus 配置
mybatis-plus:
mapper-locations: classpath*:/mapper/*Mapper.xml
mapper-locations: classpath*:/mapper/*Mapper.xml # mapper文件位置
global-config:
banner: false
banner: false # 是否打印 mybatis-plus banner
db-config:
id-type: auto
where-strategy: not_empty
insert-strategy: not_empty
update-strategy: not_null
type-handlers-package: com.pig4cloud.pig.common.mybatis.handler
id-type: auto # 主键类型
where-strategy: not_empty # where 条件策略
insert-strategy: not_empty # 插入策略
update-strategy: not_null # 更新策略
type-handlers-package: com.pig4cloud.pig.common.mybatis.handler # 类型处理器包
configuration:
jdbc-type-for-null: 'null'
call-setters-on-nulls: true
shrink-whitespaces-in-sql: true
jdbc-type-for-null: 'null' # 是否设置字段为null
call-setters-on-nulls: true # 是否调用set方法时传入null值
shrink-whitespaces-in-sql: true # 去掉sql中多余的空格
71 changes: 71 additions & 0 deletions pig-boot/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
小技巧: 在根pom里面设置统一存放路径,统一管理方便维护
<properties>
<log-path>/Users/lengleng</log-path>
</properties>
1. 其他模块加日志输出,直接copy本文件放在resources 目录即可
2. 注意修改 <property name="${log-path}/log.path" value=""/> 的value模块
-->
<configuration debug="false" scan="false">
<property name="log.path" value="logs/${project.artifactId}"/>
<!-- 彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN"
value="${CONSOLE_LOG_PATTERN:-%clr(%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}}"/>
<!-- 彩色日志依赖的渲染类 -->
<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"/>
<!-- Console log output -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
</encoder>
</appender>

<!-- Log file debug output -->
<appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/debug.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
</encoder>
</appender>

<!-- Log file error output -->
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
</appender>

<logger name="org.activiti.engine.impl.db" level="DEBUG">
<appender-ref ref="debug"/>
</logger>

<!--nacos 心跳 INFO 屏蔽-->
<logger name="com.alibaba.nacos" level="OFF">
<appender-ref ref="error"/>
</logger>
<!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
<root level="INFO">
<appender-ref ref="console"/>
<appender-ref ref="debug"/>
<appender-ref ref="error"/>
</root>
</configuration>

0 comments on commit dc985eb

Please sign in to comment.