1、运行Spring Boot
对于Spring Boot的运行,程序员GG在开发中,直接可在idea和eclipse等开发工具中,run/debug,执行入口函数SpringBootApplication;至于在测试环境和生产环境,我们一般运行的是通过Maven 打的jar包。
2、跳过测试用例
mvn clean package -Dmaven.test.skip=true
3、快速执行
java -jar api-1.0-SNAPSHOT.jar
java -jar api-1.0-SNAPSHOT.jar –spring.profiles.active=dev
4、后台运行
nohup java -jar ./api-1.0-SNAPSHOT.jar &
即使你关掉了终端,程序仍能可以访问。
配合配置文件
nohup java -jar ./api-1.0-SNAPSHOT.jar –spring.profiles.active=prod &
5、常见的Shell脚本
检查是否运行服务check.sh
#!/bin/sh
APP_NAME=api-1.0-SNAPSHOT
tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'App is running.'
else
echo 'App is NOT running.'
fi
启动服务start.sh
#!/bin/sh
APP_NAME=api-1.0-SNAPSHOT
tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'App is running.'
else
echo 'App is NOT running.'
fi
bogon:test dy_bom$ cat start.sh
#!/bin/sh
rm -f tpid
nohup java -jar ./car-league-qc.jar --spring.profiles.active=prod &
echo $! > tpid
echo Start Success!
停止服务stop.sh
#!/bin/sh
APP_NAME=api-1.0-SNAPSHOT
tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Stop Process...'
kill -15 $tpid
fi
sleep 5
tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Kill Process!'
kill -9 $tpid
else
echo 'Stop Success!'
fi
注意事项:脚本与j a r同一级目录