1、指定端口
java -jar MyApp.jar --server.port=8980
2、指定配置文件
java -jar MyApp.jar --spring.profiles.active=dev
3、同时指定端口与配置文件
java -jar MyApp.jar --server.port=8980 --spring.profiles.active=dev
1、后台服务方式启动
nohup java -jar MyApp.jar --server.port=8980 >outlog.log 2>&1 &
nohup java -jar MyApp.jar --server.port=8980 &
2、加载服务器配置文件application-dev.yml
nohup java -Dserver.port=8980 -Dspring.config.additional-location=./application-test.yml -jar ./MyApp.jar> nohup.out 2>&1 &
3、代码内获取外部化配置文件路径:
nohup java -jar authentication-1.0.0-SNAPSHOT.jar --spring.cloud.bootstrap.location=/opt/service/bootstrap.yml > /opt/service/cas.log@Value("${spring.cloud.bootstrap.location}")
private String path;