springBoot打包发布项目------jar包

时间:2023-03-09 01:17:05
springBoot打包发布项目------jar包

这两年微服务很流行,这里简单介绍一下如何将自己使用idea写的微服务打包成一个可执行的jar包,并发布到linux服务器的步骤。因为spring boot有内置的tomcat所以一般使用内置的tomcat就可以可,当然也使用外部的tomcat容器。

步骤1: 
File->Project Structure 
springBoot打包发布项目------jar包

步骤2: 
Project Settings->Artifacts->JAR->From modules with dependencies 
springBoot打包发布项目------jar包

步骤3: 
选择启动类->OK 
springBoot打包发布项目------jar包

步骤4: 
copy to the output directory and link via manifest->OK 
springBoot打包发布项目------jar包

步骤5: 
Apply->OK 
springBoot打包发布项目------jar包

步骤6: 
Build->Build Artifacts 
springBoot打包发布项目------jar包

步骤7: 
demo01.jar->Build 
springBoot打包发布项目------jar包

步骤8: 
自己写的项目成功生成一个可执行的jar包 
springBoot打包发布项目------jar包

步骤9: 
将该文件夹复制到对应的服务器上 
springBoot打包发布项目------jar包

步骤10:

<1>首次部署当前程序需要在对应的文件夹中执行以下命令

a.启动程序 nohup java -jar demo01.jar & 
b.退出 ctrl + c 
c.查看日志 tail -500f nohup.out

<2>非首次部署当前程序需要在对应的文件夹中执行以下命令

a.捕获上一个版本程序的进程 ps - ef|grep demo01.jar 
b.杀死对应的进程 kill 进程号 
c.启动程序 nohup java -jar demo01.jar & 
d.退出 ctrl + c 
e.查看日志 tail -500f nohup.out