maven打包
mvn clean install -U -DskipTests
执行jar文件
java -jar skr_java-0.0.1-SNAPSHOT.jar
更改服务端口
application.properties
配置文件格式可修改为yaml文件格式application.yaml
server.port=****
pom.xml多套开发环境配置
<profiles>
<!--指定开发环境-->
<profile>
<id>dev</id>
<properties>
<spring.profiles.active>dev</spring.profiles.active>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<!--多套环境 测试环境-->
<profile>
<id>test</id>
<properties>
<spring.profiles.active>test</spring.profiles.active>
</properties>
</profile>
</profiles>
服务器启动服务
端口指定优先级
shell命令 > application-x.properties > application.properties
1、创建shell脚本 xxx.sh
# 指定最大最小内存及方法大小
# 脚本最好加上使环境变量生效,防止因环境变量问题导致服务启动失败
nohup java -Xms256m -Xm512m -XX:PermSize=64m -XX:MaxPermSize=128m -server -Dserver.port=8080 -jar xxxxx.jar 'xxxxx' --spring.profiles.active=dev >>./test_info_8080.log 2>&1 &
# 相关操作命令
ps -ef | grep xxxxx # 查询已经存在的xxxxx进程,进程号为6666
kill -9 6666 # 杀进程
sh xxx.sh # 执行启动命令
tail -f test_info_8080.log # 查看日志