spring-boot-plus詳細配置
公共配置 application.yml
Tomcat相關配置
server:
servlet:
context-path: /api
tomcat:
max-threads: 1000
min-spare-threads: 30
uri-encoding: UTF-8
- context-path:項目訪問路徑
- max-threads:tomcat線程池大小設置
- min-spare-threads:tomcat初始化線程數量
- uri-encoding:tomcat編碼
應用程序相關配置
spring:
application:
name: spring-boot-plus
banner:
charset: UTF-8
location: classpath:config/banner.txt
- spring.application.name:項目名稱
- banner.charset:banner字符集
- banner.location:banner文件路徑
數據庫驅動及DRUID數據源配置
datasource:
driver-class-name: com.mysql.jdbc.Driver
druid:
filter:
slf4j:
enabled: true
stat:
log-slow-sql: true
merge-sql: true
slow-sql-millis: 3000
wall:
config:
delete-allow: true
drop-table-allow: false
enabled: true
filters: stat,wall,slf4j
initial-size: 10
max-active: 100
max-pool-prepared-statement-per-connection-size: 20
max-wait: 60000
min-evictable-idle-time-millis: 300000
min-idle: 10
pool-prepared-statements: true
stat-view-servlet:
enabled: true
login-password: druid123
login-username: druid
url-pattern: /druid/*
test-on-borrow: false
test-on-return: false
test-while-idle: true
time-between-eviction-runs-millis: 60000
validation-query: SELECT 1 FROM DUAL
type: com.alibaba.druid.pool.DruidDataSource
- driver-class-name:數據庫驅動類名稱
- slow-sql-millis:SQL慢查詢時間,這裏定義爲超過3秒及爲慢查詢,會在打印ERROR日誌
- url-pattern:druid登陸路徑
- login-username:druid登陸帳號
- login-password:druid登陸密碼
- druid更多說明和配置: 👉 https://github.com/alibaba/druid
HTTP編碼
http:
encoding:
charset: UTF-8
enabled: true
force: true
Jackson日期和時區配置
jackson:
date-format: yyy-MM-dd HH:mm:ss
time-zone: GMT+8
當前項目環境配置
profiles:
active: '@profileActive@'
Redis配置
redis:
jedis:
pool:
max-active: 2000
max-wait: -1ms
min-idle: 8
max-idle: 200
timeout: 10s
lettuce:
pool:
max-active: 200
max-idle: 8
max-wait: 10s
min-idle: 2
shutdown-timeout: 3s
- max-active:最大激活數
- max-wait:最大等待時間,-1ms標識一直等待,可根據實際狀況修改
- min-idle:最小存活數
- max-idle: 最小存活數
- timeout:超時時間
Rabbit MQ配置
rabbitmq:
host: 39.106.37.56
port: 5672
username: admin
password: admin123
template:
# 啓用重試機制,重試間隔時間爲2s,最多重試3次
retry:
enabled: true
initial-interval: 2s
max-attempts: 3
queue: spring-boot-plus-queue
# 定義默認的交換機名稱
exchange: spring-boot-plus-exchange
# 定義默認的路由key
routing-key: spring-boot-plus-key
- host:rabbitmq server主機
- port:端口
- username:帳號
- password:密碼
- retry.enabled:啓用重試機制
- retry.initial-interval:重試間隔時間
- retry.max-attempts:最多重試次數
- queue:隊列名稱
- exchange:交換機名稱
- routing-key:路由key名稱
Kafka MQ配置
kafka:
bootstrap-servers: 203.104.37.38:9092
producer:
retries: 0
batch-size: 4096
buffer-memory: 40960
consumer:
group-id: spring-boot-plus-group
template:
default-topic: spring-boot-plus-topic
- bootstrap-servers:server主機和端口
- producer:生產者配置
- consumer:消費者配置
- default-topic:默認主題配置
JWT配置
spring-boot-plus:
jwt:
header: token
secret: 666666
issuer: spring-boot-plus
subject: spring-boot-plus-jwt
audience: web
expire-minutes: 2
- header:請求頭中jwt名稱
- secret:密碼
- issuer:發行人
- subject:主題
- audience:應用場景
- expire-minutes:過時分鐘數
- 更多詳情:👉 https://jwt.io/
攔截器路徑排除配置
interceptor:
jwt:
exclude:
path: /swagger-resources/**,/api-docs/**,/v2/api-docs/**,/login,/verificationCode,/doc/**,/error/**,/docs,/test/**
permission:
exclude:
path: /swagger-resources/**,/api-docs/**,/v2/api-docs/**,/adminLogin,/sysLogin,/login.html,/verificationCode,/doc/**,/error/**,/docs
token-timeout:
exclude:
path: /swagger-resources/**,/api-docs/**,/v2/api-docs/**,/docs
- jwt.exclude.path:jwt攔截器排除路徑
- permission.exclude.path:權限攔截器排除路徑
- token-timeout.exclude.path:token超時攔截器排除路徑
mybatis-plus配置
mybatis-plus:
check-config-location: true
configuration:
map-underscore-to-camel-case: true
global-config:
db-config:
field-strategy: not_empty
id-type: id_worker
logic-delete-value: 0
logic-not-delete-value: 1
mapper-locations: classpath*:mapper/**/*Mapper.xml
- check-config-location:檢查路徑配置
- map-underscore-to-camel-case:下換線自動轉駝峯
- id-type:主鍵生成策略,id_worker使用雪花算法,生成全局惟一有序ID
- mapper-locations:mapper xml 路徑
- 更多mybatis-plus配置,請查看 👉 https://mybatis.plus/config/
Swagger2配置
swagger:
base:
package: io.geekidea.springbootplus
contact:
email: geekidea@qq.com
name: geekidea
url: ''
description: ''
title: spring-boot-plus
url: ''
version: 1.0
Spring Boot Admin 後臺監控配置
spring:
boot:
admin:
client:
url: 'http://localhost:8888'
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: ALWAYS
項目自定義屬性配置,結合spring boot admin使用
info:
project-groupId: '@project.groupId@'
project-artifactId: '@project.artifactId@'
project-name: '@project.name@'
project-finalName: '@project.build.finalName@'
project-author: ${swagger.contact.name}
project-description: '@project.description@'
project-sourceEncoding: '@project.build.sourceEncoding@'
project-spring-boot-version: '@spring-boot.version@'
project-mybatis-plus-version: '@mybatis-plus-boot-starter.version@'
project-version: '@project.version@'
- project-groupId:項目maven組ID
- project-artifactId:項目骨架ID
- project-name:項目名稱
- project-finalName:項目打包後的名稱
- project-author:項目做者
- project-description:項目描述
- project-sourceEncoding:項目源代碼編碼
- project-spring-boot-version:spring boot版本
- project-mybatis-plus-version:mybatis-plus版本
- project-version:項目版本
本地環境 application-local.yml
本地環境相關配置,若是公共配置中有相關配置,則會覆蓋
登陸token超時配置
springbootplus:
isEnableAnsi: true
login:
token:
valid:
time:
minute: 3600
- isEnableAnsi:在控制檯日誌是否帶有顏色,本地開發環境能夠設置爲true,服務器環境上設置爲false
- minute:token超時分鐘數
端口相關配置
server:
port: 8888
servlet:
context-path: /
- port:本地環境端口
- context-path:本地環境項目路徑
數據庫相關配置
spring:
datasource:
url: jdbc:mysql://localhost:3306/spring_boot_plus?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: root
- url:數據庫鏈接信息
- username:帳號
- password:密碼
redis相關配置
redis:
database: 0
host: localhost
password:
port: 6379
- database:數據庫序號
- host:主機
- password:密碼
- port:密碼
其它環境相似本地環境