✔
首先在资源目录下创建3个yaml配置文件:
其中application-dev.yaml和application-test.yaml分别是开发环境和测试环境。application.yaml用来控制使用哪个环境的配置文件。
application.yaml代码如下。其中active后面只需写其他两个配置环境application-后面的字符串就行了,比如active: dev就是使用8080端口,active: test就是使用8081端口。
spring:
profiles:
active: test
application-dev.yaml代码如下:
server:
port: 8080
application-test.yaml代码如下:
server:
port: 8081