項(xiàng)目配置
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!--這里對(duì)應(yīng)項(xiàng)目的主入口-->
<mainClass>xxx.xxx.RestApplication</mainClass>
<includes>
<include>
<groupId>nothing</groupId>
<artifactId>nothing</artifactId>
</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<!--將依賴包復(fù)制到lib下-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<!-- 依賴包輸出目錄褐澎,將來(lái)不打進(jìn)jar包里 -->
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<excludeScope>provided</excludeScope>
</configuration>
</execution>
</executions>
</plugin>
啟動(dòng)腳本, 全部使用絕對(duì)路徑
stop.sh
PID=$(ps -ef|grep jar文件名|grep -v grep|awk '{print $2}')
if [ -z $PID ]; then
echo "process not exist"
exit
else
echo "process id: $PID"
kill -9 ${PID}
echo "process killed"
fi
start.sh
/xxxx/xxxxx/stop.sh
nohup java -jar -Xms512M -Xmx2048M -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./dump -XX:+UseConcMarkSweepGC -Djava.ext.dirs=/xxxx/xxxxx/lib -Dspring.profiles.active=dev /xxxx/xxxxx/xxxxx-1.0.0.jar > /xxxx/xxxxx/out.log 2>&1 &
Jenkins配置