英文:
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
英文:
If the port is already used, you could simply change the port by adding this line to application.properties
:
server.port=8081
答案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);
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论