优化启动配置,properties改为yml
yml缩进严格
把之前的配置转换为yml的文件重写一下
一、application.yml
# 环境配置, dev和prod
spring:
profiles:
active: dev
一、application-dev.yml
# 测试服务端口
server:
port: 1234
servlet:
# safari中文乱码问题
encoding:
force: true
spring:
# 关闭模板引擎
thymeleaf:
check-template-location: false # 不检查templates目录
enabled: false # 关闭
# 数据库配置
datasource:
name: test
url: jdbc:mysql://localhost:3306/a2j?characterEncoding=utf-8
username: root
password: 12345678
driver-class-name: com.mysql.cj.jdbc.Driver
# 保活时间
hikari:
max-lifetime: 500000
# mybatis配置
mybatis:
# 数据库映射
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.a2j
configuration:
map-underscore-to-camel-case: true # 数据库下划线字段转换驼峰
cache-enabled: false
# logger 日志打印与备份
logging:
level:
com.a2j.mapper.*: debug
config: classpath:log/logback-dev.xml
# 老的日志打印方式
# file:
# name: logs/a2j.log
# pattern:
# console: %d %-5level %logger : %msg%n
# file: %d %-5level [%thread] %logger : %msg%n
一、application-prod.yml
# 正式服务端口
server:
port: 12345
servlet:
# safari中文乱码问题
encoding:
force: true
spring:
# 关闭模板引擎
thymeleaf:
check-template-location: false # 不检查templates目录
enabled: false # 关闭
# 数据库配置
datasource:
name: test
url: jdbc:mysql://localhost:3306/a2j?characterEncoding=utf-8
username: root
password: 12345678
driver-class-name: com.mysql.cj.jdbc.Driver
# 保活时间
hikari:
max-lifetime: 500000
# mybatis配置
mybatis:
# 数据库映射
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.a2j
configuration:
map-underscore-to-camel-case: true # 数据库下划线字段转换驼峰
cache-enabled: false
# logger 日志打印与备份
logging:
level:
com.a2j.mapper.*: debug
config: classpath:log/logback-dev.xml
# 老的日志打印方式
# file:
# name: logs/a2j.log
# pattern:
# console: %d %-5level %logger : %msg%n
# file: %d %-5level [%thread] %logger : %msg%n