春季无法启动嵌入式Tomcat服务器。

huangapple go评论67阅读模式
英文:

Spring unable to start embedded tomcat server

问题

我尝试遵循这个教程:使用WebSocket构建交互式Web应用程序

我使用eclipse、debian10、maven 3.6、jdk1.8、tomcat8。

在导入git项目后,我想运行“complete”文件夹。但是我收到以下错误消息:
org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server [...]

我没有编辑任何内容,所以我真的不知道这个错误可能来自哪里。

英文:

I try to follow this tutorial: Using WebSocket to build an interactive web application.

I use eclipse, debian10, maven 3.6, jdk1.8, tomcat8.

After importing the git project I want to run the "complete" folder. However I get the following error:
org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server [...]

I did not edit anything so I am really confused where this error might come from.

答案1

得分: 2

如果端口已经被使用,您可以通过将以下行添加到 application.properties 来更改端口:

server.port=8081

Baeldung

英文:

If the port is already used, you could simply change the port by adding this line to application.properties:

server.port=8081

Baeldung

答案2

得分: 1

显然,端口8080已经被占用。
我通过简单地更改Spring Boot应用程序的端口来解决了这个问题,就像这样编辑了MessagingStompWebsocketApplication.java文件:

@SpringBootApplication
public class MessagingStompWebsocketApplication {
  public static void main(String[] args) {
    SpringApplication app = new SpringApplication(MessagingStompWebsocketApplication.class);
    app.setDefaultProperties(Collections.singletonMap("server.port", "8089"));
    app.run(args);
  }
}
英文:

Apparently the port 8080 was already in use.
I solved the issue by simply changing the port of the spring boot application like this

edited MessagingStompWebsocketApplication.java

@SpringBootApplication
public class MessagingStompWebsocketApplication {
  public static void main(String[] args) {
    SpringApplication app = new SpringApplication(MessagingStompWebsocketApplication.class);
    app.setDefaultProperties(Collections.singletonMap("server.port","8089"));
    app.run(args);
  }
}

huangapple
  • 本文由 发表于 2020年9月1日 00:42:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/63674821.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定