gpt4 book ai didi

java - org.springframework.boot.context.embedded.PortInUseException : Port 80 is already in use

转载 作者:行者123 更新时间:2023-12-01 10:03:19 24 4
gpt4 key购买 nike

当应用程序通过 STS 作为 Spring Boot 运行来启动时,会发生这种情况。

Spring 启动:1.4.0.M1

我有一个在端口 80 上运行的 IIS,但我已通过 STS 配置属性将 sever.port 更改为 8090STS Screen shot

为什么STS嵌入的tomcat更改后仍然使用80端口?有点困惑。

2016-04-15 05:22:03,985 [main] ERROR o.s.boot.SpringApplication - Application startup failed org.springframework.boot.context.embedded.PortInUseException: Port 80 is already in use at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.checkThatConnectorsHaveStarted(TomcatEmbeddedServletContainer.java:187) at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:170) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:293) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:141) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:540) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:768) at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:362) at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1183) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1172) at com.jbhunt.web.FinanceClaimsApplication.main(FinanceClaimsApplication.java:71)

除了上述之外,我没有找到更改端口的选项提及。任何帮助将不胜感激。

最佳答案

您可以配置测试类,以使用随机端口 ( working-with-random-ports ) 加载上下文。

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)

WebEnvironment 可以使用常量进行设置:RANDOM_PORT、DEFINED_PORT、MOCK 或 NONE。

The webEnvironment attribute allows specific “web environments” to be configured for the test. You can start tests with a MOCK servlet environment or with a real HTTP server running on either a RANDOM_PORT or a DEFINED_PORT.

关于java - org.springframework.boot.context.embedded.PortInUseException : Port 80 is already in use,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36644836/

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