常用配置
server:
port: 8888
tomcat:
uri-encoding: UTF-8
servlet:
context-path: /
spring配置
# Spring配置
spring:
# 模板引擎
thymeleaf:
mode: HTML
encoding: utf-8
# 禁用缓存
cache: false
# 资源信息
messages:
# 国际化资源文件路径
basename: static/i18n/messages
jackson:
time-zone: GMT+8
date-format: yyyy-MM-dd HH:mm:ss
profiles:
active: druid
# 文件上传
servlet:
multipart:
# 单个文件大小
max-file-size: 10MB
# 设置总上传的文件大小
max-request-size: 20MB
# 服务模块
devtools:
restart:
# 热部署开关
enabled: true
mybatis配置
# MYBATIS
mybatis:
# configLocation: classpath:mybatis-config.xml
mapper-locations: classpath:mapper/*.xml # // 注意在单数据时,这配置文件,和springboot启动文件上配置了,扫描路劲,我们要把他干掉。因为我们上边的,
pagehelper:
helperDialect: mysql
reasonable: true
supportMethodsArguments: true
params: count=countSql
数据源配置
# MySQL
spring:
datasource:
url: jdbc:mysql://localhost:3306/database?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
username: root
password: password
driver-class-name: com.mysql.cj.jdbc.Driver
# Oracle
spring:
datasource:
url: jdbc:oracle:thin:@localhost:1521/database
username: system
password: password
driverClassName: oracle.jdbc.driver.OracleDriver
# SqlServer
spring:
datasource:
url: jdbc:sqlserver://localhost:1433;DatabaseName=database
username: sa
password: password
driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
# Postgre
spring:
datasource:
platform: postgres
url: jdbc:postgresql://localhost:3433/database?useSSL=false
username: root
password: password
driverClassName: org.postgresql.Driver
数据库连接池配置
# 数据源配置
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
druid:
# 主库数据源
master:
url: jdbc:sqlserver://localhost:3433; DatabaseName=database
username: root
password: password
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: true
url: jdbc:sqlserver://localhost:3433; DatabaseName=database
username: root
password: password
zform6:
# 从数据源开关/默认关闭
enabled: true
url: jdbc:sqlserver://localhost:3433; DatabaseName=database
username: root
password: password
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 10
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
# webStatFilter:
# enabled: true
statViewServlet:
enabled: true
# 设置白名单,不填则允许所有访问
allow:
url-pattern: /monitor/druid/*
filter:
stat:
# enabled: true
# 慢SQL记录
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
日志配置
logging:
level:
root: INFO
org.springframework: INFO
org.mybatis: INFO
logback-spring.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="consoleLog" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>
%d - %msg%n
</pattern>
</layout>
</appender>
<appender name="fileInfoLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>
INFO
</level>
<onMatch>
DENY
</onMatch>
<onMismatch>
ACCEPT
</onMismatch>
</filter>
<encoder>
<pattern>
%msg%n
</pattern>
</encoder>
<!-- 滚动策略 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 路径 -->
<fileNamePattern>
G:/logs/project-info.%d.log
</fileNamePattern>
</rollingPolicy>
</appender>
<appender name="fileErrorLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>
ERROR
</level>
</filter>
<encoder>
<pattern>
%msg%n
</pattern>
</encoder>
<!-- 滚动策略 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 路径 -->
<fileNamePattern>
G:/logs/project-error.%d.log
</fileNamePattern>
</rollingPolicy>
</appender>
<root level="info">
<appender-ref ref="consoleLog" />
<appender-ref ref="fileInfoLog" />
<appender-ref ref="fileErrorLog" />
</root>
</configuration>
本文用于自己学习记录,也参考了很多前辈的博客,如有不当的地方,还请各位大佬多多指教,手动ღ( ´・ᴗ・` )比心