Spring Boot 配置文件示例:数据库、MyBatis Plus 和日志配置
下面是一个常用的 Spring Boot 配置文件 'application.yml',其中包含了数据库、MyBatis Plus 和日志等相关的配置内容:
# 应用名称
spring:
application:
name: myapp
# 数据库配置
spring:
datasource:
url: jdbc:mysql://localhost:3306/mydb?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
driver-class-name: com.mysql.jdbc.Driver
username: root
password: root
# MyBatis Plus 配置
mybatis-plus:
global-config:
db-config:
id-type: auto
field-strategy: not_empty
logic-delete-value: 1
logic-not-delete-value: 0
table-prefix: my_
# 日志配置
logging:
level:
root: info
com.myapp: debug
file:
path: /var/log/myapp
name: myapp.log
max-history: 7
max-size: 10MB
以上配置文件中,分别包含了如下内容:
- 应用名称:'spring.application.name'
- 数据库配置:'spring.datasource.url'、'spring.datasource.driver-class-name'、'spring.datasource.username'、'spring.datasource.password'
- MyBatis Plus 配置:'mybatis-plus.global-config.db-config.id-type'、'mybatis-plus.global-config.db-config.field-strategy'、'mybatis-plus.global-config.db-config.logic-delete-value'、'mybatis-plus.global-config.db-config.logic-not-delete-value'、'mybatis-plus.global-config.db-config.table-prefix'
- 日志配置:'logging.level.root'、'logging.level.com.myapp'、'logging.file.path'、'logging.file.name'、'logging.file.max-history'、'logging.file.max-size'
其中,'logging.level.root' 表示根日志级别为 'info','logging.level.com.myapp' 表示 'com.myapp' 包下的日志级别为 'debug','logging.file.path' 表示日志文件的存储路径,'logging.file.name' 表示日志文件的名称,'logging.file.max-history' 表示日志文件最大保留天数,'logging.file.max-size' 表示日志文件最大大小。
原文地址: https://www.cveoy.top/t/topic/lB7u 著作权归作者所有。请勿转载和采集!