spring - spring boot地址和端口号问题
问题描述
我正在寻找此处报告的问题的可能根本原因(SO 线程) - 无法在 eclipse 中启动 Tomcat v9.0 服务器。
在摆弄上面(与上面提到的线程无关)时,不小心,而不是
server.port=8080
我把下面放在我的 application.properties 文件中
server.address=8080
当我尝试启动服务器时,在我意识到错字之前一直收到此错误。
***************************
APPLICATION FAILED TO START
***************************
Description:
Web server failed to start. Port 8080 was already in use
当我用“端口”替换“地址”时,一切正常。
问题:是预期行为还是已知缺陷或可能的新缺陷?如果它是一个新缺陷,我在哪里可以在 Spring Community 上报告它?
更新
根据 github 问题跟踪器https://github.com/spring-projects/spring-boot/issues/21101上的评论,它现在已修复,修复将在下一个版本 2.2.7 中发布
解决方案
Spring Boot 无法将服务器绑定到无效地址 8080。
默认消息是
Web 服务器无法启动。8080 端口已被使用
你可以尝试设置
server.addresss=9090
你会得到同样的信息。
错误消息只是误导。
消息生成于PortInUseFailureAnalyzer
并在这里抛出 PortInUseException:
public void start() throws WebServerException {
synchronized (this.monitor) {
if (this.started) {
return;
}
try {
addPreviouslyRemovedConnectors();
Connector connector = this.tomcat.getConnector();
if (connector != null && this.autoStart) {
performDeferredLoadOnStartup();
}
checkThatConnectorsHaveStarted();
this.started = true;
logger.info("Tomcat started on port(s): " + getPortsDescription(true) + " with context path '"
+ getContextPath() + "'");
}
catch (ConnectorStartFailedException ex) {
stopSilently();
throw ex;
}
catch (Exception ex) {
if (findBindException(ex) != null) {
throw new PortInUseException(this.tomcat.getConnector().getPort());
}
throw new WebServerException("Unable to start embedded Tomcat server", ex);
}
finally {
Context context = findContext();
ContextBindings.unbindClassLoader(context, context.getNamingToken(), getClass().getClassLoader());
}
}
}
推荐阅读
- html - Bootsrap 4 网格或 Flex
- python - 转到下一条路线Django时总是双加链接
- tabulator - 制表器:单击小图像时全屏显示原始图像
- c - 有没有办法在不构建树的情况下从其后序遍历中找到严格二叉树的前序遍历?
- java - 从图库、ImageBitmap 和 ImageURI 显示图像似乎不起作用
- javascript - 项目中项目的 JS -> 承诺链得到错误的值
- mysql - 在 MySQL 中提取 JSON 提取的第一个键
- javascript - 使用 TypeScript 为带有裸 ES 模块的浏览器编译模块
- node.js - npm install 不会创建 node_modules 文件夹
- mysql - 需要使用 SQL 在热编码数据集上实现 k 均值聚类