Correct the classpath of your application so that it contains a single, compatible version of javax.

用springboot简单开发helloworld时遇到的问题:
示意图:

The method's class, javax.servlet.ServletContext, is available from the following locations:

    jar:file:/C:/Program%20Files/Java/jdk1.8.0_131/jre/lib/ext/servlet-api.jar!/javax/servlet/ServletContext.class
    jar:file:/C:/Program%20Files/Java/jdk1.8.0_131/jre/lib/ext/servlet-api.jar!/javax/servlet/ServletContext.class
    jar:file:/E:/Maven/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.33/tomcat-embed-core-9.0.33.jar!/javax/servlet/ServletContext.class

It was loaded from the following location:

    file:/C:/Program%20Files/Java/jdk1.8.0_131/jre/lib/ext/servlet-api.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of javax.servlet.ServletContext

原因:jdk和Maven里的那个包里都有ServeltContext.class 冲突了,即springboot自带tomcat,tomcat有servlet-api,和jdk里面的冲突了;
方法:按照JDK的路径找到那个包,然后把那个Jar包删除即可运行正常。

如果有更好的办法,欢迎指教!

你可能感兴趣的:(BUG集锦)