SpringBoot Profile多环境支持
多profiles文件使用spring.profiles.active=dev没有生效,需要在pom.xml文件中增加
<!-- profile多环境支持需要配置 --> <build> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> </build>
applicaiton.properties,需要切换环境只需要在application.properties中修改spring.profiles.active=dev或者prod
server.port=8089
spring.profiles.active=dev
application-dev.properties
server.port=8081
application-prod.properties
server.port=8082
yaml文件配置
spring:
profiles:
active: dev
---
server:
port: 8084
spring:
profiles: dev
---
server:
port: 8085
spring:
profiles: prod
yaml文件和properties文件只能存在一种,使用yaml文件需要把properties文件里的内容全部注释掉。
posted on 2022-04-11 15:59 lovezj9012 阅读(27) 评论(0) 收藏 举报
浙公网安备 33010602011771号