问题8080已经在监听java spring

问题描述 投票:0回答:1

我的 java Spring 端口 8080 所以永远不会断开连接。即使我停止应用程序,该进程仍保持打开状态。这意味着当我启动项目并在代码修改后再次重新启动它时,我会看到它已经在监听。这是同一个项目。因此,如果我重新启动项目,每次代码行发生更改时,我都必须转到 currport 来停止该过程。如果我更改 application.properties 中的端口,我指示的所有端口都会显示“已在侦听”,而最终 currport 在这些端口上找不到任何进程。因此,我浪费了大量时间在每次启动同一个项目之间杀死 8080 进程,这是我以前从未做过的事情,我在另外 2 台 PC 上有 java,但它不会这样做,我可以重新运行一个项目,而无需杀死进程。当我启动我的项目时,它会监听一个端口,只要我不停止它,无论我启动我的项目1次还是10次,监听都是一样的。我不知道有什么变化,但它只影响我在 8080 上的所有 Spring 项目,在另一个端口上启动 Web 服务的所有其他项目都没有这个问题。我以前从未遇到过这个问题。

2024-04-13T15:03:49.253+02:00  INFO 4584 --- [  restartedMain] com.example.calcul.CalculApplication     : Starting CalculApplication using Java 21.0.2 with PID 4584 (C:\Users\chres\Documents\jetBrainProjects\intellij-idea-projects\calcul\target\classes started by chres in C:\Users\chres\Documents\jetBrainProjects\intellij-idea-projects\calcul)
2024-04-13T15:03:49.256+02:00  INFO 4584 --- [  restartedMain] com.example.calcul.CalculApplication     : No active profile set, falling back to 1 default profile: "default"
2024-04-13T15:03:49.314+02:00  INFO 4584 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2024-04-13T15:03:49.315+02:00  INFO 4584 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2024-04-13T15:03:50.575+02:00  INFO 4584 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port 8080 (http)
2024-04-13T15:03:50.587+02:00  INFO 4584 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2024-04-13T15:03:50.588+02:00  INFO 4584 --- [  restartedMain] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.19]
2024-04-13T15:03:50.637+02:00  INFO 4584 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2024-04-13T15:03:50.639+02:00  INFO 4584 --- [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1322 ms
2024-04-13T15:03:51.267+02:00  WARN 4584 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : Unable to start LiveReload server
2024-04-13T15:03:51.288+02:00  WARN 4584 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'
2024-04-13T15:03:51.302+02:00  INFO 4584 --- [  restartedMain] .s.b.a.l.ConditionEvaluationReportLogger : 

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2024-04-13T15:03:51.323+02:00 ERROR 4584 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

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

Description:

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

Action:

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

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.912 s
[INFO] Finished at: 2024-04-13T15:03:51+02:00
[INFO] ------------------------------------------------------------------------

Process finished with exit code 0

即使我更改 application.properties 中的端口,它也会给我带来同样的问题,我放置的所有端口都已经在侦听,而不存在具有这些端口的进程。

这不是另一个可以被指控的进程,因为当我通过 currport 停止端口 8080 上的进程时,我的项目再次运行,但我在之后重新启动它,它再次给我一个错误,因为端口繁忙,所以在重新启动我的项目之前它已经在监听,我必须手动停止该进程,你能想象每次修改代码时都这样做吗?

按红色按钮停止该过程没有任何效果。 谢谢

spring port
1个回答
0
投票

要首先解决此问题,您需要打开命令行 (cmd) 并输入:

netstat -ano |查找字符串:8080

这将识别正在使用 8080 端口的进程 ID,

然后在同一命令行上键入以下命令:

taskkill /PID < PID > /F

其中必须替换为您之前刚刚识别的进程号。

我希望这有帮助

在我的例子中,红色之间的数字是进程 ID 号 [1]:https://i.stack.imgur.com/939uM.png

© www.soinside.com 2019 - 2024. All rights reserved.