springboot project jar package runs

springboot project jar package runs

reference

Linux running in the background java jar package

step

  1. Enter maven project, packaged the project. mvn package -Dmaven.test.skip=true
  2. Run jar.java -jar upload-01-0.0.1-SNAPSHOT.jar
  3. Stop jar.

windows running springboot project jar package

run

Method One: java -jar upload-01-0.0.1-SNAPSHOT.jarforeground, close the command line window, the process terminates.

Method Two: Double-jar package. Background process.

Examples of a method of

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

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

stop

Method one: Close the command line window.

Method two: to kill the process.netstat -ano | findstr 80 taskkill -pid 27768 -f

Method II Examples

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 running springboot project jar package

run

method one:java -jar upload-01-0.0.1-SNAPSHOT.jar

Foreground, losing cursor. Xshell closed session, the process is terminated.

Method Two:java -jar upload-01-0.0.1-SNAPSHOT.jar &

Running in the background, close xshell session, the process is terminated, the information is output to the current session window.

Method three:nohup java -jar upload-01-0.0.1-SNAPSHOT.jar &

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

Running in the background, close xshell session, the process does not terminate, the default output information to the current directory nohup.out. Input can be redirected to the specified file.

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

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

Examples of a method of

[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)

Method II Examples

[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]# 

Method three examples

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: 忽略输入重定向错误到标准输出端

stop

Method One: Turn off xshell session window.

Method two: ctrl + z release the cursor, then kill the process.netstat -ntlp | grep 80 kill -9 2460

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

ctrl+z Release the cursor.

[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]# 

Guess you like

Origin www.cnblogs.com/mozq/p/11876561.html