Springboot项目部署linux服务器
Archie_java 人气:0springboot的jar包方式
- idea默认就是jar打包方式所以直接使用maven工具按照步骤点击就可以直接打包
ps:打包前你的数据库相关的连接信息要记得修改,不能再用本地的了
第二步
:Maven clean :清除编译后的目录,默认是target目录
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building cwgl 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ cwgl ---
[INFO] Deleting D:\FFM\cwgl\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.265 s
[INFO] Finished at: 2020-05-27T10:47:44+08:00
[INFO] Final Memory: 11M/121M
[INFO] ------------------------------------------------------------------------
Process finished with exit code 0
第三步
: Maven package:打包
[INFO] --- maven-jar-plugin:3.1.0:jar (default-jar) @ cwgl ---
[INFO] Building jar: D:\FFM\cwgl\target\cwgl-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.1.1.RELEASE:repackage (repackage) @ cwgl ---
[INFO] Replacing main artifact with repackaged archive
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.605 s
[INFO] Finished at: 2020-05-27T11:11:24+08:00
[INFO] Final Memory: 43M/272M
[INFO] ------------------------------------------------------------------------
Process finished with exit code 0
第四步
:到target目录下找到 jar包
第五步
:将jar包放到linux的任意文件夹(可访问)下
第六步
:输入 java -jar 文件名.jar
ps:这样有一个问题就是当你终端关闭后,就不能访问了,或者说隔一段时间后就不能访问了
如何解决这个问题呢 ?使用nohup
nohup java -jar 文件名.jar &
1、nohup的意思不挂服务,常驻的意思,除非云服务器重启,那就没法了;
2、最后一个&表示执行命令后要生成日志文件nohup.out=
出现:nohup: ignoring input and appending output to ‘nohup.out'
正常情况,显目启动成功
检测:最后在浏览器地址栏输入项目地址,检查项目是否部署成功
加载全部内容