在springboot工程中配置文件编写的时候可以使用application-{profile}.properties/yml,默认使用application.properties/yml,例如:
每个环境配置如下:
#application-dev.properties
server.port=8080
#application-test.properties
server.port=8082
#application-dev.properties
server.port=80
我们可以在application.properties/yml指定激活哪个环境的配置文件,我们在发布的时候最终都是读取application.properties/yml中的配置:
#yml
spring:
profiles:
active: @profiles.active@ # 和我们pom.xml中的指定resource配置相同
#properties
spring.profiles.active=dev
pom.xml配置如下:
<dependencies>
<!-- Add typical dependencies for a web application web应用的依赖-->
<dep