【问题标题】:Spring Boot with debug args not close debug port after application stopped应用程序停止后,带有调试参数的 Spring Boot 不会关闭调试端口
【发布时间】:2018-06-14 06:42:06
【问题描述】:

我正在运行启用调试模式的 Spring Boot 应用程序。喜欢:

mvn -P dev spring-boot:run -Drun.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"

之后我可以毫无问题地调试应用程序。但是,在停止 (ctrl + c) 并尝试重新启动后,我收到此错误:

[INFO] Attaching agents: []
ERROR: transport error 202: bind failed: Address already in use
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [debugInit.c:750]

因此,之后每次我需要在调试模式下启动应用程序时,我都需要使用端口 5005 终止进程。

我想知道为什么停止应用后5005端口仍然打开。

我在 Windows 10、Maven 3.5.2、Java 8 和 Spring Boot 1.5.9.RELEASE 上使用 Cygwin64。

谢谢!

【问题讨论】:

    标签: java spring maven debugging port


    【解决方案1】:

    这不是Spring Boot的问题,而是非cygwin应用在cygwin中运行的问题。而且您的应用程序不仅打开了 5005 端口,它还在后台继续运行,同时打开了 8080 端口,但是在重新启动时,调试端口首先打开,这就是您在错误消息中看到的内容。

    早在 2014 年 https://github.com/spring-projects/spring-boot/issues/773 的 SpringBoot 问题中就已对此进行了讨论。我从这个问题中引用(引用中的链接日期为 2006 年):

    任何人仍在关注此错误,这根本不是 Spring Boot 错误。这是在基于 pty 的终端上运行的非 Cygwin 程序(在本例中为 Java)的一个已知问题。

    请参阅此链接以获取无法修复此问题的完整说明:http://cygwin.com/ml/cygwin/2006-12/msg00151.html

    所以你基本上可以使用以下方法之一:

    1. 使用本机 Windows 终端并为此设置您的 java 和 maven 环境
    2. 从可以处理此问题的 IDE 中运行您的 maven 命令 - 您也可以将其用于调试
    3. 将 Spring Actuator 添加到您的应用程序并使用 /shutdown 端点停止您的应用程序

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-08
      • 1970-01-01
      • 1970-01-01
      • 2020-08-03
      • 2020-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多