在启动我的 spring boot 应用程序时看到一个神秘的 ClassCastException。 我最近开始看到这个问题,没有对任何配置进行任何更改。 我们如何调试这个问题?
org.springframework.context.ApplicationContextException: Unable to start embedded container;
nested exception is java.lang.ClassCastException:
org.apache.tomcat.websocket.WsWebSocketContainer cannot be cast to io.undertow.websockets.jsr.ServerWebSocketContainer
at io.undertow.websockets.jsr.Bootstrap.handleDeployment(Bootstrap.java:62) ~[undertow-websockets-jsr-1.3.5.Final.jar:1.3.5.Final]
at io.undertow.servlet.core.DeploymentManagerImpl.handleExtensions(DeploymentManagerImpl.java:246) ~[undertow-servlet-1.3.5.Final.jar:1.3.5.Final]
信息: 这是 build info
最佳答案
你不需要这个依赖。
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-undertow</artifactId> </dependency>
如果您要使用 tomcat 服务器,则不需要任何 tomcat 依赖项,因为在 spring boot 中默认容器是 Tomcat。
<dependency> <groupId>org.apache.tomcat</groupId> <artifactId>tomcat-jsp-api</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> <scope>provided</scope> </dependency>
关于java - 启动 Spring Boot 应用程序时发生 ClassCastException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34745729/