首先項目須要引用Maven的SpringBoot插件
<profiles> <profile> <id>boot-repackage</id> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.18.1</version> <configuration> <skipTests>true</skipTests> </configuration> </plugin> </plugins> </build> </profile> </profiles>
啓動項目腳本java
以項目名爲rongyuan-project爲例需先執行中止項目腳本
#!/bin/sh sh bin/stop.sh git pull nohup mvn spring-boot:run -Drun.profiles=prod & #springboot2.x以上版本的插件發佈 #爲了規避指令衝突參數統一加上spring-boot前綴spring-boot.run.profiles=prod #jar包發佈腳本爲 java -jar -Dspring.profiles.active=prod tailf nohup.out
項目中止腳本git
以項目名爲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:spring
在項目中mkdir bin文件夾,而後在bin目錄下touch start.sh與stop.sh,便可在項目中執行腳本,而且目錄結構也更加優美.