[jar package running and termination]

Run the jar package

enterjava -jar 要运行的jar包.jar

Terminate running the jar package

There are two steps:
① To query the PID of running jar, enter the following command:

C:\Users\Administrator\IdeaProjects\springflutterdemo\target>jps
12916
13764 Jps
14680 RemoteMavenServer36
14748 springflutterdemo-0.0.1-SNAPSHOT.jar
14844 Launcher

② Kill the process

taskkill /pid 进程的PID编号 -f  -t

example

C:\Users\Administrator\IdeaProjects\springflutterdemo\target>java -jar springflutterdemo-0.0.1-SNAPSHOT.jar

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

2023-03-16 08:25:41.577  INFO 13440 --- [           main] c.e.s.SpringflutterdemoApplication       : Starting SpringflutterdemoApplication v0.0.1-SNAPSHOT using Java 15 on JieLenovoPC with PID 13440 (C:\Users\Administrator\IdeaProjects\springflutterdemo\target\springflutterdemo-0.0.1-SNAPSHOT.jar started by Administrator in C:\Users\Administrator\IdeaProjects\springflutterdemo\target)
2023-03-16 08:25:41.593  INFO 13440 --- [           main] c.e.s.SpringflutterdemoApplication       : No active profile set, falling back to 1 default profile: "default"
2023-03-16 08:25:42.939  INFO 13440 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8099 (http)
2023-03-16 08:25:42.953  INFO 13440 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2023-03-16 08:25:42.954  INFO 13440 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.65]
2023-03-16 08:25:43.039  INFO 13440 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2023-03-16 08:25:43.040  INFO 13440 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1368 ms
Logging initialized using 'class org.apache.ibatis.logging.stdout.StdOutImpl' adapter.
Parsed mapper file: 'class path resource [mapper/UserMapper.xml]'
2023-03-16 08:25:43.768  WARN 13440 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.PortInUseException: Port 8099 is already in use
2023-03-16 08:25:43.773  INFO 13440 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2023-03-16 08:25:43.787  INFO 13440 --- [           main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-03-16 08:25:43.810 ERROR 13440 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   :

***************************
APPLICATION FAILED TO START
***************************

Description:

Web server failed to start. Port 8099 was already in use.

Action:

Identify and stop the process that's listening on port 8099 or configure this application to listen on another port.


C:\Users\Administrator\IdeaProjects\springflutterdemo\target>jps
12916
13764 Jps
14680 RemoteMavenServer36
14748 springflutterdemo-0.0.1-SNAPSHOT.jar
14844 Launcher

C:\Users\Administrator\IdeaProjects\springflutterdemo\target>taskkill /pid 14748 -f  -t
成功: 已终止 PID 14748 (属于 PID 12916 子进程)的进程。

C:\Users\Administrator\IdeaProjects\springflutterdemo\target>

Guess you like

Origin blog.csdn.net/qq_44255741/article/details/129579267