Caused by: java.lang.ClassCastException: org.springframework.web.SpringServletContainerInitializer cannot be cast to javax.servlet.ServletContainerInitializer。。。。。检查一下servlet-api是否冲突了?

原因:jar包发生冲突。在我的pom.xml文件中

<dependency>  
    <groupId>javax.servlet</groupId>  
    <artifactId>javax.servlet-api</artifactId>  
    <version>3.1.0</version>  
</dependency> 

当程序运行时与tomcat中的jar包冲突了,只需要它在测试、编译阶段有用
可以限制作用范围,改成如下

<dependency>  
    <groupId>javax.servlet</groupId>  
    <artifactId>javax.servlet-api</artifactId>  
    <scope>provided</scope>  
    <version>3.1.0</version>  
</dependency> 

猜你喜欢

转载自www.cnblogs.com/liu2-/p/9111749.html
今日推荐