一.新建多个application.properties文件,分别为:
application.properties
application-dev.properties->server.port=1111
application-sit.properties->server.port=2222
application-prod.properties->server.port=3333
二、项目根目录mvn打包
mvn install
三、启动项目
默认端口:java -jar xxxxx.jar:默认启动xxxxx项目的application.properties文件,如果没有设置server.prot则端口默认为8080。
指定端口:
1.在application.properties文件中设置配置文件:spring.profiles.active=dev【dev/sit/prod】
2.在启动时指定配置文件:java -jar xxxxx.jar --spring.profiles.active=dev【dev/sit/prod】