CentOS部署SpringBoot

1、將SpringBoot項(xiàng)目打包成jar,詳見(jiàn) eclipse中,將springboot項(xiàng)目打成jar包

2、將jar包復(fù)制到CentOS系統(tǒng)中,可參考 CentOS7掛載windows下的共享文件夾

3、關(guān)閉CentOS防火墻

CentOS 7.0默認(rèn)使用的是firewall作為防火墻

查看防火墻狀態(tài)

firewall-cmd --state

停止firewall

systemctl stop firewalld.service

禁止firewall開(kāi)機(jī)啟動(dòng)

systemctl disable firewalld.service

開(kāi)機(jī)啟用firewall

systemctl enable firewalld.service

4、新建SpringBoot服務(wù)

1) 進(jìn)入/etc/systemd/system目錄

cd /etc/systemd/system

2) 創(chuàng)建服務(wù)

touch hello.service

3) 服務(wù)設(shè)置,往“hello.service”添加如下內(nèi)容

根據(jù)自己的情況修改 DescriptionExecStart 的內(nèi)容,其中 java -jar xxx.jar 是啟動(dòng)服務(wù)的關(guān)鍵。

[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.服務(wù)操作

啟動(dòng)服務(wù)

systemctl start hello

or

systemctl start hello.service

停止服務(wù)

systemctl stop hello

or

systemctl stop hello.service

服務(wù)狀態(tài)

systemctl status hello

or

systemctl status hello.service

開(kāi)機(jī)啟動(dòng)

systemctl enable hello

or

systemctl enable hello.service

項(xiàng)目日志

journalctl -u hello

or

journalctl -u hello.service

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容