Java-端口被占用导致无法启动项目

2019年09月29日 10:38 · 阅读(784) ·

说明

项目代码参考 Java - 类型转换公共类

这里只列出关键代码

开发环境

名称 版本
操作系统 Windows 10 X64
JDK JDK1.8(jdk-8u151-windows-x64)
IntelliJ IDEA IntelliJ IDEA 2018.3
Maven Maven 3.6.0

问题描述

启动 service 项目时,报下面错误

  1. Caused by: java.net.BindException: Address already in use: bind
  2. Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
  3. 2019-09-29 10:27:26.283 ERROR [service-producer,,,] 14036 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
  4. ***************************
  5. APPLICATION FAILED TO START
  6. ***************************
  7. Description:
  8. The Tomcat connector configured to listen on port 18800 failed to start. The port may already be in use or the connector may be misconfigured.
  9. Action:
  10. Verify the connector's configuration, identify and stop any process that's listening on port 18800, or configure this application to listen on another port.

原因分析

根据错误描述可以看出,是端口被占用了

原因是我在 IntelliJ IDEA 2018.3 开了两个项目,另一个项目中已经成功启动了 service 项目,它们的端口都是 18800

问题解决

关闭另外一个已经成功启动的 service 项目即可
或者改变为另外一个端口号