1.有一个总的配置文件application.yml,通过activve来激活使用哪个环境的配置
2.所有环境配置相同的内容可以放到总的配置文件里,不同的配置就各写一套(例如:每个环境连接的数据库不同,所以application.yml中的数据库配置已经注释掉/删掉)
application.yml
spring:
profiles:
active: dev
#数据库配置
#spring:
# datasource:
# driver-class-name: com.mysql.cj.jdbc.Driver
# username: root
# password:
# url: jdbc:mysql://ip:3306/数据库名?&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
#允许循环依赖
main:
allow-circular-references: true
#mybatis和实体类、xml的映射
mybatis:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.example.entity
pagehelper:
helper-dialect: mysql
reasonable: true
support-methods-arguments: true
params: count=countSql
application-pro.yml
server:
port: 8089
#数据库配置
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver