Port 8080 was already in use 的报错原文是什么,Boot 4 变了吗?同一个端口、不同绑定地址时第二个实例会不会启动成功?这篇用两个真实实例逐个试。
Boot 4.0.8(退出码 1,用时 0.8s)
启动失败 org.springframework.context.ApplicationContextException ← org.springframework.boot.web.server.PortInUseException
Description:
Web server failed to start. Port <端口> was already in use.
Action:
Identify and stop the process that's listening on port <端口> or configure this application to listen on another port.PortInUseException,Description 与 Action 的文字。
Boot 3.5.16(退出码 1,用时 1.0s)
启动失败 org.springframework.context.ApplicationContextException ← org.springframework.boot.web.server.PortInUseException
Description:
Web server failed to start. Port <端口> was already in use.
Action:
Identify and stop the process that's listening on port <端口> or configure this application to listen on another port.与 4.0.8 一致。
Boot 4.0.8:第二个实例启动成功,两个实例同时在运行
向 127.0.0.1:端口 连续请求 6 次,响应来自:第一个 第一个 第一个 第一个 第一个 第一个两个实例同时运行,请求去向取决于绑定地址。
Boot 4.0.8:第二个实例启动成功,两个实例同时在运行
向 127.0.0.1:端口 连续请求 6 次,响应来自:第一个 第一个 第一个 第一个 第一个 第一个第二个设 127.0.0.1 也能启动,6 次请求全去了第一个。
server.port=0(随机端口)(退出码 0,用时 0.8s)
启动成功,local.server.port 是一个正数server.port=0。