前言
一直在ide中敲代码,使用命令行mvn spring-boot:run
或者gradlew bootRun
来运行spring boot项目。
部署为可运行的jar
spring boot已经尽可能把需要配置的东西自动化了,我还傻傻的像以前springmvc那样补充各种配置,比如加一个数据源druid。然而大可不必,使用默认的就好,等需求不满足的时候,在进行修改就可以了。
运行方式:java -jar xxxx.jar
看到比较好的linux脚本:
start.sh
#!/bin/shrm -f tpidnohup java -jar xx.jar --spring.profiles.active=dev > /dev/null 2>&1 &echo $! > tpidecho Start Success!
stop.sh
#!/bin/shAPP_NAME=myapptpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`if [ ${tpid} ]; then echo 'Stop Process...' kill -15 $tpidfisleep 5tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`if [ ${tpid} ]; then echo 'Kill Process!' kill -9 $tpidelse echo 'Stop Success!'fi
check.sh
#!/bin/shAPP_NAME=myapptpid=`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
kill.sh
#!/bin/shAPP_NAME=myapptpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`if [ ${tpid} ]; then echo 'Kill Process!' kill -9 $tpidfi