gpt4 book ai didi

java - tomcat连接器更改端口

转载 作者:行者123 更新时间:2023-11-28 22:39:42 24 4
gpt4 key购买 nike

我在 Spring Boot 中实现了一个简单的“Hello World”。我正在学习教程 SpringBoot HelloWorld

当我将类 SpringbootHelloworldApplication.java 作为“Run as Java Aplication”运行时,出现错误:

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


Description:

The Tomcat connector configured to listen on port 8080 failed to start. The port may already be in use or the connector may be misconfigured.

Action:

Verify the connector's configuration, identify and stop any process that's listening on port 8080, or configure this application to listen on another port.

我确实双击了服务器,它有这样的配置:

enter image description here

我没有使用端口 8080,我应该在哪里更改默认端口?

server.xml 文件有:

  <Connector port="8085" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />

最佳答案

我假设您的应用程序看起来像这样:

@SpringBootApplication
public class Application {

public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

Spring Boot 运行嵌入式 Tomcat 服务器。当你运行 SpringbootHelloworldApplication.java 类时,它实际上启动了它自己的服务器。您根本不需要 Eclipse Tomcat 连接器。

您可能已经启动了应用程序的另一个实例。

尝试设置 server.port=0。这将导致 Spring Boot 每次启动时都使用随机空闲端口。

关于java - tomcat连接器更改端口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47416418/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com