springboot项目jar包运行

参考

Linux后台运行java的jar包

步骤

  1. 进入maven项目中,打包项目。 mvn package -Dmaven.test.skip=true
  2. 运行jar。java -jar upload-01-0.0.1-SNAPSHOT.jar
  3. 停止jar。

windows中运行springboot的项目jar包

运行

方法一:java -jar upload-01-0.0.1-SNAPSHOT.jar 前台运行,关闭命令行窗口,进程终止。

方法二:双击jar包。后台运行。

方法一实例

D:\00\02>java -jar upload-01-0.0.1-SNAPSHOT.jar

  .   ____          _            __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.1.RELEASE)

停止

方法一:关闭命令行窗口。

方法二:杀死进程。netstat -ano | findstr 80 taskkill -pid 27768 -f

方法二实例

C:\Users\jie>netstat -ano | findstr 80
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 27768
TCP 0.0.0.0:8081 0.0.0.0:0 LISTENING 8928 C:\Users\jie>taskkill -pid 27768 -f
成功: 已终止 PID 为 27768 的进程。

Linux中运行springboot的项目jar包

运行

方法一:java -jar upload-01-0.0.1-SNAPSHOT.jar

前台运行,失去光标。关闭xshell会话,进程终止。

方法二:java -jar upload-01-0.0.1-SNAPSHOT.jar &

后台运行,关闭xshell会话,进程终止,信息被输出到当前会话窗口。

方法三:nohup java -jar upload-01-0.0.1-SNAPSHOT.jar &

nohup java -jar webapp/upload-01-0.0.1-SNAPSHOT.jar > test.log &

后台运行,关闭xshell会话,进程不会终止,信息默认输出到当前目录下 nohup.out。可以重定向输入到指定文件。

nohup 意思是不挂断运行命令,当账户退出或终端关闭时,程序仍然运行。

当用 nohup 命令执行作业时,缺省情况下该作业的所有输出被重定向到当前目录下nohup.out的文件中,除非另外指定了输出文件。

方法一实例

[root@frxxCentOS webapp]# rz

[root@frxxCentOS webapp]# ls
upload-01-0.0.1-SNAPSHOT.jar
[root@frxxCentOS webapp]# java -jar upload-01-0.0.1-SNAPSHOT.jar
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.1.RELEASE)

方法二实例

[root@frxxCentOS webapp]# java -jar upload-01-0.0.1-SNAPSHOT.jar &
[1] 9714
[root@frxxCentOS webapp]#
[root@frxxCentOS webapp]#
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.1.RELEASE) [root@frxxCentOS webapp]#

方法三实例

nohup java -jar upload-01-0.0.1-SNAPSHOT.jar &

[root@frxxCentOS webapp]# nohup java -jar upload-01-0.0.1-SNAPSHOT.jar &
[2] 10350
[root@frxxCentOS webapp]# nohup: 忽略输入并把输出追加到"nohup.out"
[root@frxxCentOS webapp]# ls
nohup.out upload-01-0.0.1-SNAPSHOT.jar

nohup java -jar webapp/upload-01-0.0.1-SNAPSHOT.jar &

# 当前目录是/root ,在当前目录下生成nohup文件。

[root@frxxCentOS ~]# nohup java -jar webapp/upload-01-0.0.1-SNAPSHOT.jar &
[1] 11113
[root@frxxCentOS ~]# nohup: 忽略输入并把输出追加到"nohup.out"
[root@frxxCentOS ~]# pwd
/root
[root@frxxCentOS ~]# ls
anaconda-ks.cfg nohup.out q webapp

nohup java -jar webapp/upload-01-0.0.1-SNAPSHOT.jar > test.log &

[root@frxxCentOS ~]# nohup java -jar webapp/upload-01-0.0.1-SNAPSHOT.jar > test.log &
[2] 11282
[root@frxxCentOS ~]# nohup: 忽略输入重定向错误到标准输出端

停止

方法一:关闭xshell会话窗口。

方法二:ctrl+z 释放光标,然后杀死进程。netstat -ntlp | grep 80 kill -9 2460

^Z
[1]+ 已停止 java -jar upload-01-0.0.1-SNAPSHOT.jar

ctrl+z 释放光标。

[root@frxxCentOS webapp]# netstat -ntlp | grep 80
tcp6 3 0 :::80 :::* LISTEN 2460/java
[root@frxxCentOS webapp]# kill -9 2460
[root@frxxCentOS webapp]# netstat -ntlp |grep 80
[1]+ 已杀死 java -jar upload-01-0.0.1-SNAPSHOT.jar

bugs

# ctrl+z 释放光标仍然杀不死进程,有一个 tcp6协议的80端口。
^Z
[1]+ 已停止 java -jar upload-01-0.0.1-SNAPSHOT.jar
[root@frxxCentOS webapp]# netstat -ntlp |grep 80
tcp6 0 0 :::80 :::* LISTEN 9929/java
[root@frxxCentOS webapp]# java -jar upload-01-0.0.1-SNAPSHOT.jar . ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.1.RELEASE) 2019-11-17 14:25:41.066 WARN 10113 --- [ main] o.s.boot.StartupInfoLogger : InetAddress.getLocalHost().getHostName() took 10036 milliseconds to respond. Please verify your network configuration.
2019-11-17 14:25:51.085 INFO 10113 --- [ main] c.m.boot.upload01.Upload01Application : Starting Upload01Application v0.0.1-SNAPSHOT on frxxCentOS with PID 10113 (/root/webapp/upload-01-0.0.1-SNAPSHOT.jar started by root in /root/webapp)
2019-11-17 14:25:51.086 INFO 10113 --- [ main] c.m.boot.upload01.Upload01Application : No active profile set, falling back to default profiles: default
2019-11-17 14:25:54.145 INFO 10113 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 80 (http)
2019-11-17 14:25:54.186 INFO 10113 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-11-17 14:25:54.187 INFO 10113 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.27]
2019-11-17 14:25:54.380 INFO 10113 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/mozq] : Initializing Spring embedded WebApplicationContext
2019-11-17 14:25:54.381 INFO 10113 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3176 ms
2019-11-17 14:25:55.794 INFO 10113 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-11-17 14:25:56.210 INFO 10113 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2019-11-17 14:25:56.236 INFO 10113 --- [ main] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-11-17 14:25:56.237 ERROR 10113 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : ***************************
APPLICATION FAILED TO START
*************************** Description: Web server failed to start. Port 80 was already in use. Action: Identify and stop the process that's listening on port 80 or configure this application to listen on another port. 2019-11-17 14:25:56.241 INFO 10113 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
[root@frxxCentOS webapp]#

springboot项目jar包运行的更多相关文章

  1. 部署SpringBoot项目jar包到云服务器

    前言 做安卓开发也有三四年了,但是对网络这块什么http.tcp/ip之类的一直不理解.并且想自己做一些小项目练练手的时候,数据库直接存在apk里总不是滋味,所以这次站在安卓开发的角度尝试着做一做简单 ...

  2. shell脚本运行springboot项目jar包

    #!/bin/bash APP_NAME=AutomationGuide-0.0.1-SNAPSHOT.jar #使用说明,用来提示输入参数 usage() { echo "please e ...

  3. SpringBoot项目jar包启动脚本

    startup.bat @echo off set path=X:\xxxxxxx\Java\JDK\jre\bin START "项目名" "%path%\java&q ...

  4. SpringBoot:springboot项目jar包如何引入外置配置文件

            springboot项目打成jar包,默认读取的classpath路径下的配置文件,config.properties是自定义配置文件. 如果要把config.properties配置 ...

  5. 在CentO7系统上配置Springboot项目jar包开机自启动

    官方文档地址:https://docs.spring.io/spring-boot/docs/current/reference/html/deployment.html#deployment-ins ...

  6. springBoot 项目 jar/war打包 并运行

    一:idea  打jar  包 简述:springboor  项目最好的打包方式就是打成jar  ,下边就是简单的过程 1.打开idea工具 ,选着要打开的项目, 然后打开view--> too ...

  7. Springboot 打jar包分离lib,配置文件正确方式(二)

    Springboot 打jar包分离lib,配置文件正确方式(二) 背景 从<Springboot 打jar包分离lib,配置文件正确方式>中,可以达到把配置文件和依赖第三方的jar包分离 ...

  8. Docker部署web项目-jar包

    一.Docker部署web项目-jar包 ①搜索mysql镜像 docker search mysql ②拉取镜像至本地仓库(本文选取的mysql镜像5.7版本) docker pull mysql/ ...

  9. 由提交storm项目jar包引发对jar的原理的探索

    序:在开发storm项目时,提交项目jar包当把依赖的第三方jar包都打进去提交storm集群启动时报了发现多个同名的文件错误由此开始了一段对jar包的深刻理解之路. java.lang.Runtim ...

随机推荐

  1. div里面的元素在【垂直 方向】上水平分布 使用calc()函数动态计算

    1==>如何让div里面的元素在[垂直 方向]上水平分布.important-dec{ height: 121px; //必须固定高度 flex-direction: column; //垂直排 ...

  2. 整理几个经常在H5移动端开发遇到的东西。

    本篇主要是我个人的学习分享. 1.弹出数字键盘 <!-- 有“#” “*” 符号输入 --> <input type="tel"> <!-- 纯数字 ...

  3. 201871010106-丁宣元 《面向对象程序设计(java)》第十二周学习总结

    201871010106-丁宣元 <面向对象程序设计(java)>第十二周学习总结 正文开头: 项目 内容 这个作业属于哪个课程 https://home.cnblogs.com/u/nw ...

  4. 《2018:skymind.ai 发布了一份非常全面的开源数据集》

    这是一份非常全面的开源数据集,你,真的不想要吗?   近期,skymind.ai 发布了一份非常全面的开源数据集.内容包括生物识别.自然图像以及深度学习图像等数据集,现机器之心将其整理如下:(内附链接 ...

  5. CometOJ10C 鱼跃龙门

    题目链接 problem 实际上就是对于给定的\(n\)求一个最小的\(x\)满足\(\frac{x(x+1)}{2}=kn(k\in N^*)\). solution 对上面的式子稍微变形可得\(x ...

  6. Spring 中AOP及前后置增强案例

    1.AOP面向切面编程 面向切面编程的本质:面向切面编程,指扩展功能不修改源代码,将功能代码从业务逻辑代码中分离出来.  1主要功能:日志记录,性能统计,安全控制,事务处理,异常处理等等.  2主要意 ...

  7. python同名函数同名参数问题

    如果python有两个函数的函数名与参数列表都相同那么调用该函数时,哪个函数在后,则哪个被最终调用. 举例如下: def test(): print "before hello" ...

  8. Java 泛型示例 - 泛型方法,类,接口

    Java Genrics 是 Java 5 中引入的最重要的功能之一. 如果您一直在使用Java Collections并使用版本 5 或更高版本,那么我确定您已经使用过它. Java 中具有集合类的 ...

  9. VSCode 开发插件 推荐

    VSCode 必装的 10 个高效开发插件  本文介绍了目前前端开发最受欢迎的开发工具 VSCode 必装的 10 个开发插件,用于大大提高软件开发的效率. VSCode 的基本使用可以参考我的原创视 ...

  10. jQuery 源码分析(十九) DOM遍历模块详解

    jQuery的DOM遍历模块对DOM模型的原生属性parentNode.childNodes.firstChild.lastChild.previousSibling.nextSibling进行了封装 ...