【问题标题】:Web server failed to start and port 10086 was already in use in IntelliJ IDEA 2021Web 服务器无法启动且端口 10086 已在 IntelliJ IDEA 2021 中使用
【发布时间】:2021-08-10 06:45:08
【问题描述】:

Web 服务器无法启动,并且端口 10086 已在 IntelliJ IDEA 2021 中使用。当我运行 netstat -ano |findstr 10086 时,终端中没有任何输出。这里有什么问题? 有什么帮助吗?

PS C:\Windows\System32> netstat -ano |findstr 10086
PS C:\Windows\System32>

控制台输出:

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

Description:

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

Action:

Identify and stop the process that's listening on port 10086 or configure this application to listen on another port.
 (LoggingFailureAnalysisReporter.java:40)

【问题讨论】:

  • 识别并停止正在侦听端口 10086 的进程或将此应用程序配置为侦听另一个端口。 - 还有什么要做的?
  • @ScaryWombat 如何在 Windows 上找到监听 10086 端口的进程?使用此命令netstat -ano |findstr 10086,我在终端中没有任何输出。

标签: java spring-boot intellij-idea


【解决方案1】:

您可以使用 server.port 在 application.properties 中设置其他未使用的端口,如下所示

server.port = 10087

【讨论】:

  • 您不需要重新启动操作系统。您只需要在更改端口后重新启动应用程序
  • 我已经更改了启动应用程序的端口,但它仍然抛出已经与新 server.port 一起使用的端口。也许操作系统或 IntelliJ IDEA 有问题。
  • 您指定的端口已被其他进程使用。在更改端口之前,请确保它未使用。您可以使用netstat -ano | findstr:<port> 进行检查
【解决方案2】:

您好,请确保您在控制台中输入正确。

不工作检查示例

如果您不想启动嵌入式服务器,只需在 application.properties(或 .yml)中设置以下属性:

  spring.main.web-application-type=none

来源:https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto-embedded-web-servers

如果您的应用程序确实是 Web 应用程序,那么您可以使用 server.port 属性轻松更改端口(在应用程序的 .properties/.yaml 文件中,作为启动时的命令行参数等)。

【讨论】:

    猜你喜欢
    • 2020-11-27
    • 1970-01-01
    • 2019-10-23
    • 1970-01-01
    • 2022-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-20
    相关资源
    最近更新 更多