springboot項目,直接打包成jar
自帶tomcat,可以通過java命令直接運行,無需web應用服務.
以maven為例,在pom.xml中配置打包輸出類型:
<packaging>jar</packaging>
配置build:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
打包成jar后,可以通過批處理直接啟動或者停止.
window-bat
start:
@echo off
:wmic process where "commandline like '%%-jar reportcheck%%'" call terminate
set path=C:\Program Files\Java\jre1.8.0_91\bin
START "reportcheck" "%path%\javaw" -jar reportcheck-0.0.1-SNAPSHOT.jar
pause
stop:
@echo off
wmic process where "commandline like '%%-jar reportcheck%%'" call terminate
pause
unix-sh
start:
#!/bin/bash
if ps aux | grep -v 'grep' | grep 'java' | grep 'reportcheck.jar'
then
pid=$(ps aux | grep -v 'grep' |grep 'java'|grep 'reportcheck.jar'| awk '{print $2}');
echo pid;
kill -9 ${pid};
echo old reportcheck exit...;
fi
nohup java -jar reportcheck.jar &> out &
echo reportcheck running...
stop:
#!/bin/bash
if ps aux | grep -v 'grep' | grep 'java' | grep 'reportcheck.jar'
then
pid=$(ps aux | grep -v 'grep' |grep 'java'|grep 'reportcheck.jar'| awk '{print $2}');
echo pid
kill -9 ${pid};
fi