使用Maven脚本在Centos服务器中启动与停止项目
首先项目需要引用Maven的SpringBoot插件
boot-repackage org.springframework.boot spring-boot-maven-plugin org.apache.maven.plugins maven-surefire-plugin 2.18.1 true
启动项目脚本
以项目名为rongyuan-project为例需先执行停止项目脚本
#!/bin/sh sh bin/stop.sh git pull nohup mvn spring-boot:run -Drun.profiles=prod & tailf nohup.out
项目停止脚本
以项目名为rongyuan-project为例
#!/bin/bash PID=$(ps -ef | grep rongyuan-project | grep -v grep | awk '{ print $2 }') if [ -z "$PID" ] then echo rongyuan is already stopped else echo kill $PID kill $PID fi
tips:在项目中mkdir bin文件夹,然后在bin目录下touch start.sh与stop.sh,即可在项目中执行脚本,并且目录结构也更加优美.
The above is the detailed content of How to start or stop the SpringBoot project in Centos. For more information, please follow other related articles on the PHP Chinese website!