美文网首页
CentOS部署SpringBoot

CentOS部署SpringBoot

作者: 树蜂 | 来源:发表于2018-11-07 14:59 被阅读0次

1、将SpringBoot项目打包成jar,详见 eclipse中,将springboot项目打成jar包

2、将jar包复制到CentOS系统中,可参考 CentOS7挂载windows下的共享文件夹

3、关闭CentOS防火墙

CentOS 7.0默认使用的是firewall作为防火墙

查看防火墙状态

firewall-cmd --state

停止firewall

systemctl stop firewalld.service

禁止firewall开机启动

systemctl disable firewalld.service

开机启用firewall

systemctl enable firewalld.service

4、新建SpringBoot服务

1) 进入/etc/systemd/system目录

cd /etc/systemd/system

2) 创建服务

touch hello.service

3) 服务设置,往“hello.service”添加如下内容

根据自己的情况修改 DescriptionExecStart 的内容,其中 java -jar xxx.jar 是启动服务的关键。

[Unit]
Description=hello
After=syslog.target
[Service]
ExecStart=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-0.el7_5.x86_64/bin/java -jar /usr/local/apps/hello-0.0.1-SNAPSHOT.jar
[Install]
WantedBy=multi-user.target

5.服务操作

启动服务

systemctl start hello

or

systemctl start hello.service

停止服务

systemctl stop hello

or

systemctl stop hello.service

服务状态

systemctl status hello

or

systemctl status hello.service

开机启动

systemctl enable hello

or

systemctl enable hello.service

项目日志

journalctl -u hello

or

journalctl -u hello.service

相关文章

网友评论

      本文标题:CentOS部署SpringBoot

      本文链接:https://www.haomeiwen.com/subject/zelvxqtx.html