实际开发中,会有很多种环境的切换,本地,测试,生产等,各环境的信息都可能不同,这时候需要配置多环境的yml文件,如下:
1:配置一个主的application.yml文件
spring:
profiles:
# 环境分支:dev本地分支|test测试分支|prod生产分支
active: test
# 配置pagehelper参数
pagehelper:
helperDialect: mysql
reasonable: true
supportMethodsArguments: true
params: count=countSql
2:配置本地的yml:命名以:application-dev.yml
#用于配置开发坏境信息
#配置服务端口号
server:
port: 8080
servlet:
context-path: /path
session:
timeout: 1800s
# 配置数据库信息
spring:
datasource:
url: jdbc:mysql://localhost:3306/***?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC
username: root
password: root
driver-class-name: com.mysql.jdbc.Driver
#Mybatis的mapper.xml文件位置
mybatis:
mapper-locations: classpath:mapper/*.xml
#配置日志输出位置
logging:
file:
path: D:\log
其他环境的yml文件类似上面,自己根据实际情况进行配置即可!!!