Centos下SpringBoot项目启动与停止脚本的方法
更新时间:2018年11月27日 14:59:04 作者:独上兰舟
这篇文章主要介绍了Centos下SpringBoot项目启动与停止脚本的方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
使用Maven脚本在Centos服务器中启动与停止项目
首先项目需要引用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>
启动项目脚本
以项目名为rongyuan-project为例需先执行停止项目脚本
#!/bin/sh sh bin/stop.sh git pull nohup mvn spring-boot:run -Drun.profiles=prod & tailf nohup.out
项目停止脚本
以项目名为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:在项目中mkdir bin文件夹,然后在bin目录下touch start.sh与stop.sh,即可在项目中执行脚本,并且目录结构也更加优美.
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
相关文章
详解使用spring boot admin监控spring cloud应用程序
这篇文章主要介绍了详解使用spring boot admin监控spring cloud应用程序,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧2018-05-05
SpringCloud基于RestTemplate微服务项目案例解析
这篇文章主要介绍了SpringCloud基于RestTemplate微服务项目案例,在写SpringCloud搭建微服务之前,先搭建一个不通过springcloud只通过SpringBoot和Mybatis进行模块之间通讯,通过一个案例给大家详细说明,需要的朋友可以参考下2022-05-05
Mybatis-Plus中的@TableName 和 table-prefix使用
table-prefix 是一个全局配置,它会自动在所有表名前添加指定的前缀,这个配置对于那些使用一致命名约定的数据库表非常有用,这篇文章主要介绍了Mybatis-Plus中的@TableName 和 table-prefix使用,需要的朋友可以参考下2024-08-08


最新评论