Centos7服务器下启动jar包项目的最佳方法

发布时间:2025-10-08 点击:18
linux运行jar包是比较常见的基础知识,今天讲解centos7服务器下启动jar包项目的最佳方法。
首先centos7 推荐我们这么运行项目
首先执行命令:
cd /ets/systemd/system
到这个目录下,新建一个 yourprojectname.service,可以把yourprojectname设置为你想起的服务名
用vi编辑一个新的文件
vi yourprojectname.service
文件名
[unit] description=yourprojectname #描述 after=syslog.target network.target #依赖 [service] type=simple execstart=/usr/bin/java -jar /opt/javaapps/yourprojectname.jar #前面是java命令的绝对路径 后面是jar包的绝对路径 execstop=/bin/kill -15 $mainpid user=root group=root [install] wantedby=multi-user.target使用
systemctl start yourprojectname
或者
systemctl start yourprojectname.service
就启动服务了。
如果更改项目了:
先运行
systemctl daemon-reload
再运行systemctl start sell.service
如果要停止服务:
systemctl stop yourprojectname
或者
systemctl stop yourprojectname.service
设置开机自启动:
systemctl enable yourprojectname
或者
systemctl enable yourprojectname.service
又或者不想开机启动:
systemctl disable yourprojectname
或者
systemctl disable yourprojectname.service
好了,到这就结束了。用规范的方式运行项目有助于后期维护。


我不能修改该域名请帮我修改成我一修改就假死
网购奢侈品如何能保证是正品
[深圳SEO]关于网站建设官网优化的重要性
网站建设费用依据什么报价?
炫云服务器多少钱一台
SSH暴力破解攻击遍布全球,看看你中招了吗?
什么是托管服务器
企业云盘服务器硬盘要多大容量合适