项目配置项
注意
redis在通用配置中设置,所有服务共用一套redis。如果需要每个服务使用不同redis的话,需要将多个服务中同时访问同一个redis的代码修改为Feign接口。
例如:认证token的代码,多个服务中都有调用
通用配置
通用配置application.yml
yml
spring:
autoconfigure:
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
redis:
host: localhost
port: 6379
password: 1qaz@WSX
database: 5
servlet:
multipart:
# 单个文件大小
max-file-size: 10MB
# 设置总上传的文件大小
max-request-size: 20MB
# feign 配置
feign:
sentinel:
enabled: true
okhttp:
enabled: true
httpclient:
enabled: false
client:
config:
default:
connectTimeout: 10000
readTimeout: 10000
compression:
request:
enabled: false
response:
enabled: false
# 暴露监控端点
management:
endpoints:
web:
exposure:
include: '*'
endpoint:
health:
show-details: always
logging:
config: classpath:logback-logstash.xml
log:
level: info
maxSize: 30MB
# 临时缓存存储时间(单位:天)
# 例如认证信息、用户信息、角色信息、字典信息等查询后会存储到临时缓存中
cache:
temp:
time: 7
网关配置
网关配置mf-gateway.yml
yml
spring:
cloud:
gateway:
discovery:
locator:
lowerCaseServiceId: true
enabled: true
routes:
# 认证中心
- id: mf-oauth
uri: lb://mf-oauth
predicates:
- Path=/oauth2/**
filters:
- CacheFilter
# 验证码处理
- CheckCodeFilter
- StripPrefix=1
# 测试中心
- id: mf-test
uri: lb://mf-test
predicates:
- Path=/test/**
filters:
- StripPrefix=1
- id: mf-code
uri: lb://mf-code
predicates:
- Path=/code/**
filters:
- StripPrefix=1
- id: mf-sys
uri: lb://mf-sys
predicates:
- Path=/sys/**
filters:
- StripPrefix=1
- id: mf-web
uri: lb://mf-web
predicates:
- Path=/web/**
filters:
- StripPrefix=1
- id: mf-storage
uri: lb://mf-storage
predicates:
- Path=/storage/**
filters:
- StripPrefix=1
- id: mf-scheduler
uri: lb://mf-scheduler
predicates:
- Path=/scheduler/**
filters:
- StripPrefix=1
- id: mf-openai
uri: lb://mf-openai
predicates:
- Path=/ai/**
filters:
- StripPrefix=1
# 安全配置
security:
# 验证码
captcha:
enabled: true
type: math
# 网关校验直接返回
gatewayCheckCaptcha:
# - /oauth2/authorize
# 网关校验,自己服务返回
selfCheckCaptcha:
- /oauth2/authorize?loginType=user_password
# 防止XSS攻击
xss:
enabled: true
excludeUrls:
# 不校验白名单
ignore:
whites:
- /oauth2/accessToken
- /oauth2/authorize
- /oauth2/sendMsg
- /oauth2/qrCodeLogin/*
- /oauth2/wx/bind/**
- /oauth2/static/**
- /storage/file/*.*
- /code/**
- /test/**
- /*/v2/api-docs
认证中心配置
认证中心配置mf-oauth.yml
yml
swagger:
title: '摸鱼认证中心'
needAuth: true
# mybatis配置
mybatis-plus:
# 搜索指定包别名
type-aliases-package: cn.com.mfish.oauth.mapper
# 配置mapper的扫描,找到所有的mapper.xml映射文件
mapper-locations: classpath*:cn/com/mfish/**/mapper/**/*Mapper.xml
global-config:
# 关闭MP3.0自带的banner
banner: false
db-config:
#主键类型 0:"数据库ID自增",1:"该类型为未设置主键类型", 2:"用户输入ID",3:"全局唯一ID (数字类型唯一ID)", 4:"全局唯一ID UUID",5:"字符串全局唯一ID (idWorker 的字符串表示)";
#id-type: 0
# 默认数据库表下划线命名
table-underline: true
#逻辑删除 删除前
logic-not-delete-value: 0
#逻辑删除 删除后
logic-delete-value: 1
configuration:
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# 返回类型为Map,显示null对应的字段
call-setters-on-nulls: true
map-underscore-to-camel-case: true
auto-mapping-behavior: full
jdbc-type-for-null:
spring:
thymeleaf:
cache: false
datasource:
druid:
stat-view-servlet:
enabled: true
loginUsername: admin
loginPassword: 123456
dynamic:
druid:
initial-size: 5
min-idle: 5
maxActive: 20
maxWait: 60000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
filters: stat,slf4j
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
datasource:
# 主库数据源
master:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/mf_oauth?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: 123456
# 从库数据源
# slave:
# username:
# password:
# url:
# driver-class-name:
# seata: true # 开启seata代理,开启后默认每个数据源都代理,如果某个不需要代理可单独关闭
redisCache:
expire: 50400
keyPrefix: sso_cache
redisSession:
expire: 50400
keyPrefix: sso_session
shiro:
security:
algorithmName: md5
hashIterations: 2
hexEncoded: true
oauth2:
expire:
code: 180
token: 21600
refreshToken: 604800
# 登录互斥开关 false不互斥 true 互斥
#打开互斥:
# 同一个用户 允许手机,微信,浏览器同时在线
# 一个用户只允许在一个手机,一个微信,一个浏览器上登录,其他浏览器登录会踢出之前的用户
#关闭互斥后:
# 用户允许多地登录
login:
mutex: false
user:
autoCreate: false
token:
sm4key: 143be1ae6ee10b048f7e441cec2a9803
wechat:
miniapp:
appId: wx****************a3
secret: a65****************fa227
代码生成配置
代码生成配置mf-code.yml
yml
swagger:
title: '摸鱼代码生成中心'
code:
template:
keys:
- ${packageName}/controller/${entityName}Controller.java.ftl
- ${packageName}/entity/${entityName}.java.ftl
- ${packageName}/mapper/${entityName}Mapper.java.ftl
- ${packageName}/mapper/xml/${entityName}Mapper.xml.ftl
- ${packageName}/req/Req${entityName}.java.ftl
- ${packageName}/service/${entityName}Service.java.ftl
- ${packageName}/service/impl/${entityName}ServiceImpl.java.ftl
- mfish-nocode-view/src/views/${apiPrefix}/${entityName#kebab-case}/${entityName#uncap_first}.data.ts.ftl
- mfish-nocode-view/src/views/${apiPrefix}/${entityName#kebab-case}/${entityName}Modal.vue.ftl
- mfish-nocode-view/src/views/${apiPrefix}/${entityName#kebab-case}/index.vue.ftl
- mfish-nocode-view/src/api/${apiPrefix}/model/${entityName}Model.ts.ftl
- mfish-nocode-view/src/api/${apiPrefix}/${entityName}.ts.ftl
path: template
savePath: D:/mfish
# mybatis配置
mybatis-plus:
# 配置mapper的扫描,找到所有的mapper.xml映射文件
mapper-locations: classpath*:cn/com/mfish/code/mapper/**/*Mapper.xml
global-config:
# 关闭MP3.0自带的banner
banner: false
db-config:
#主键类型 0:"数据库ID自增",1:"该类型为未设置主键类型", 2:"用户输入ID",3:"全局唯一ID (数字类型唯一ID)", 4:"全局唯一ID UUID",5:"字符串全局唯一ID (idWorker 的字符串表示)";
#id-type: 0
# 默认数据库表下划线命名
table-underline: true
#逻辑删除 删除前
logic-not-delete-value: 0
#逻辑删除 删除后
logic-delete-value: 1
configuration:
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# 返回类型为Map,显示null对应的字段
call-setters-on-nulls: true
map-underscore-to-camel-case: true
auto-mapping-behavior: full
jdbc-type-for-null:
spring:
datasource:
druid:
stat-view-servlet:
enabled: true
loginUsername: admin
loginPassword: 123456
dynamic:
druid:
initial-size: 5
min-idle: 5
maxActive: 20
maxWait: 60000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
filters: stat,slf4j
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
datasource:
# 主库数据源
master:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/mf_scheduler?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: 123456
# 从库数据源
# slave:
# username:
# password:
# url:
# driver-class-name:
# seata: true # 开启seata代理,开启后默认每个数据源都代理,如果某个不需要代理可单独关闭
系统业务配置
系统业务配置mf-sys.yml
yml
swagger:
title: '摸鱼系统业务中心'
# mybatis配置
mybatis-plus:
# 配置mapper的扫描,找到所有的mapper.xml映射文件
mapper-locations: classpath*:cn/com/mfish/sys/mapper/**/*Mapper.xml
global-config:
# 关闭MP3.0自带的banner
banner: false
db-config:
#主键类型 0:"数据库ID自增",1:"该类型为未设置主键类型", 2:"用户输入ID",3:"全局唯一ID (数字类型唯一ID)", 4:"全局唯一ID UUID",5:"字符串全局唯一ID (idWorker 的字符串表示)";
#id-type: 0
# 默认数据库表下划线命名
table-underline: true
#逻辑删除 删除前
logic-not-delete-value: 0
#逻辑删除 删除后
logic-delete-value: 1
configuration:
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# 返回类型为Map,显示null对应的字段
call-setters-on-nulls: true
map-underscore-to-camel-case: true
auto-mapping-behavior: full
jdbc-type-for-null:
spring:
datasource:
druid:
stat-view-servlet:
enabled: true
loginUsername: admin
loginPassword: 123456
dynamic:
druid:
initial-size: 5
min-idle: 5
maxActive: 20
maxWait: 60000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
filters: stat,slf4j
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
datasource:
# 主库数据源
master:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/mf_system?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: 123456
# 从库数据源
# slave:
# username:
# password:
# url:
# driver-class-name:
# seata: true # 开启seata代理,开启后默认每个数据源都代理,如果某个不需要代理可单独关闭
DBConnect:
password:
privateKey: 54f0e36b98cf63c3bc6185b61c6e4f2a6e1df3bdeb293a50d7b0bc66881c2419
文件中心配置
文件中心配置mf-storage.yml
yml
swagger:
title: '摸鱼文件管理'
# mybatis配置
mybatis-plus:
# 配置mapper的扫描,找到所有的mapper.xml映射文件
mapper-locations: classpath*:cn/com/mfish/storage/mapper/**/*Mapper.xml
global-config:
# 关闭MP3.0自带的banner
banner: false
db-config:
#主键类型 0:"数据库ID自增",1:"该类型为未设置主键类型", 2:"用户输入ID",3:"全局唯一ID (数字类型唯一ID)", 4:"全局唯一ID UUID",5:"字符串全局唯一ID (idWorker 的字符串表示)";
#id-type: 0
# 默认数据库表下划线命名
table-underline: true
#逻辑删除 删除前
logic-not-delete-value: 0
#逻辑删除 删除后
logic-delete-value: 1
configuration:
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# 返回类型为Map,显示null对应的字段
call-setters-on-nulls: true
map-underscore-to-camel-case: true
auto-mapping-behavior: full
jdbc-type-for-null:
spring:
datasource:
druid:
stat-view-servlet:
enabled: true
loginUsername: admin
loginPassword: 123456
dynamic:
druid:
initial-size: 5
min-idle: 5
maxActive: 20
maxWait: 60000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
filters: stat,slf4j
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
datasource:
# 主库数据源
master:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/mf_system?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: 123456
# 从库数据源
# slave:
# username:
# password:
# url:
# driver-class-name:
# seata: true # 开启seata代理,开启后默认每个数据源都代理,如果某个不需要代理可单独关闭
storage:
active: local
address: http://localhost:8888/storage/file/
local:
storagePath: storage
aliyun:
endpoint: oss-cn-hangzhou.aliyuncs.com
accessKeyId: LTAI5***********FsgT
accessKeySecret: ZtZGF***************JADjS2f
bucketName: landwise
监控中心配置
监控中心配置mf-monitor.yml
yml
swagger:
title: '摸鱼监控中心'
spring:
security:
user:
name: admin
password: 123456
boot:
admin:
ui:
title: 摸鱼监控中心
调度中心配置
调度中心配置mf-scheduler.yml
yml
swagger:
title: '摸鱼调度中心'
# mybatis配置
mybatis-plus:
# 配置mapper的扫描,找到所有的mapper.xml映射文件
mapper-locations: classpath*:cn/com/mfish/scheduler/mapper/**/*Mapper.xml
global-config:
# 关闭MP3.0自带的banner
banner: false
db-config:
#主键类型 0:"数据库ID自增",1:"该类型为未设置主键类型", 2:"用户输入ID",3:"全局唯一ID (数字类型唯一ID)", 4:"全局唯一ID UUID",5:"字符串全局唯一ID (idWorker 的字符串表示)";
#id-type: 0
# 默认数据库表下划线命名
table-underline: true
#逻辑删除 删除前
logic-not-delete-value: 0
#逻辑删除 删除后
logic-delete-value: 1
configuration:
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# 返回类型为Map,显示null对应的字段
call-setters-on-nulls: true
map-underscore-to-camel-case: true
auto-mapping-behavior: full
jdbc-type-for-null:
spring:
datasource:
druid:
stat-view-servlet:
enabled: true
loginUsername: admin
loginPassword: 123456
dynamic:
druid:
initial-size: 5
min-idle: 5
maxActive: 20
maxWait: 60000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
filters: stat,slf4j
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
datasource:
# 主库数据源
master:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/mf_scheduler?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: 123456
# 从库数据源
# slave:
# username:
# password:
# url:
# driver-class-name:
# seata: true # 开启seata代理,开启后默认每个数据源都代理,如果某个不需要代理可单独关闭
org:
quartz:
scheduler:
instanceName: MfishClusteredScheduler
instanceId: AUTO
threadPool:
poolClass: org.quartz.simpl.SimpleThreadPool
threadCount: 50
threadPriority: 5
jobStore:
jdbcClass: org.quartz.impl.jdbcjobstore.JobStoreTX
driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate
useProperties: true
isClustered: true
tablePrefix: QRTZ_
dataSource: mf_scheduler
clusterCheckinInterval: 20000
misfireThreshold: 60000
#rocketmq配置信息
rocketmq:
#nameservice服务器地址(多个以英文逗号隔开)
name-server: 127.0.0.1:9876
#生产者配置
producer:
#组名
group: mfish-scheduler-group
sendMessageTimeout: 300000
#目的地(topic:tag)
#topic
topic: mfish-scheduler-topic
普通web应用配置
普通web应用配置mf-web.yml
yml
swagger:
title: '摸鱼其他业务'
mybatis-plus:
# 配置mapper的扫描,找到所有的mapper.xml映射文件
mapper-locations: classpath*:cn/com/mfish/web/mapper/**/*Mapper.xml
global-config:
# 关闭MP3.0自带的banner
banner: false
db-config:
#主键类型 0:"数据库ID自增",1:"该类型为未设置主键类型", 2:"用户输入ID",3:"全局唯一ID (数字类型唯一ID)", 4:"全局唯一ID UUID",5:"字符串全局唯一ID (idWorker 的字符串表示)";
#id-type: 0
# 默认数据库表下划线命名
table-underline: true
#逻辑删除 删除前
logic-not-delete-value: 0
#逻辑删除 删除后
logic-delete-value: 1
configuration:
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# 返回类型为Map,显示null对应的字段
call-setters-on-nulls: true
map-underscore-to-camel-case: true
auto-mapping-behavior: full
jdbc-type-for-null:
spring:
datasource:
druid:
stat-view-servlet:
enabled: true
loginUsername: admin
loginPassword: 123456
dynamic:
druid:
initial-size: 5
min-idle: 5
maxActive: 20
maxWait: 60000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
filters: stat,slf4j
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
datasource:
# 主库数据源
master:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/mf_system?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: 123456
# 从库数据源
# slave:
# username:
# password:
# url:
# driver-class-name:
# seata: true # 开启seata代理,开启后默认每个数据源都代理,如果某个不需要代理可单独关闭
MQ消息消费端样例配置
MQ消息消费端样例配置mf-consume.yml
yml
swagger:
title: '摸鱼调度中心-MQ消费端测试'
#rocketmq配置信息
rocketmq:
#生产者配置
consumer:
nameServer: 127.0.0.1:9876
#topic
topic: mfish-scheduler-topic
#组名
group: mfish-scheduler-group
负载配置
负载配置sentinel-mf-gateway
yml
[
{
"resource": "mf-oauth",
"count": 500,
"grade": 1,
"limitApp": "default",
"strategy": 0,
"controlBehavior": 0
},
{
"resource": "mf-sys",
"count": 500,
"grade": 1,
"limitApp": "default",
"strategy": 0,
"controlBehavior": 0
},
{
"resource": "mf-storage",
"count": 100,
"grade": 1,
"limitApp": "default",
"strategy": 0,
"controlBehavior": 0
},
{
"resource": "mf-scheduler",
"count": 100,
"grade": 1,
"limitApp": "default",
"strategy": 0,
"controlBehavior": 0
},
{
"resource": "mf-code",
"count": 100,
"grade": 1,
"limitApp": "default",
"strategy": 0,
"controlBehavior": 0
}
]
日志配置
提示
日志配置logback-logstash.xml在各模块resources文件夹下
${应用名称}
自己根据模块重命名即可
log.level
和log.maxSize
会读取nacos上application.yml中的配置
日志配置logback-logstash.xml
xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<springProperty name="rootLevel" source="log.level" />
<springProperty name="maxFileSize" source="log.maxSize" />
<!-- 日志存放路径 -->
<property name="log.path" value="logs/mf-${应用名称}"/>
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
<maxFileSize>${maxFileSize}</maxFileSize>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
<charset>UTF-8</charset>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_sql" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sql.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sql.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
<maxFileSize>${maxFileSize}</maxFileSize>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<appender name="file_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}/error.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
<maxFileSize>${maxFileSize}</maxFileSize>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
<charset>UTF-8</charset>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="cn.com.mfish" level="info"/>
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn"/>
<!--数据库操作日志-->
<logger name="cn.com.mfish.${应用名称}.mapper" level="debug" additivity="true">
<appender-ref ref="file_sql"/>
</logger>
<!--系统操作日志-->
<root level="${rootLevel}">
<appender-ref ref="STDOUT"/>
<appender-ref ref="file_info"/>
<appender-ref ref="file_error"/>
</root>
</configuration>
nacos连接配置
提示
nacos连接配置bootstrap.yml在各模块resources文件夹下
${端口}
当前应用模块启动后监听端口
${应用名称}
当前应用模块名称,对应到nacos中配置名称
${nacos地址}
当前启动nacos访问地址端口
nacos中配置文件名为${应用名称}-${profiles.active}.yml
nacos连接配置bootstrap.yml
yml
mfish:
version: 1.0.0
# Tomcat
server:
port: ${端口}
# Spring
spring:
application:
# 应用名称
name: ${应用名称}
profiles:
# 环境配置
active: dev
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: ${nacos地址}
config:
# 配置中心地址
server-addr: #{nacos地址}
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs[0]:
data-id: application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
refresh: true