先看以下报错信息:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.2019-04-28 17:31:14.186 ERROR 12404 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : ***************************APPLICATION FAILED TO START***************************Description:An attempt was made to call a method that does not exist. The attempt was made from the following location: org.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1178)The following method did not exist: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;The method's class, javax.servlet.ServletContext, is available from the following locations: jar:file:/F:/jdk/jre/lib/ext/servlet-api.jar!/javax/servlet/ServletContext.class jar:file:/C:\Users\fan\.m2\repository\javax\servlet\javax.servlet-api\3.1.0\javax.servlet-api-3.1.0.jar!/javax/servlet/ServletContext.classt was loaded from the following location: jar:file:/F:/jdk/jre/lib/ext/servlet-api.jar!/javax/servlet/ServletContext.classAction:Correct the classpath of your application so that it contains a single, compatible version of javax.servlet.ServletContextProcess finished with exit code 1
注意一下这句话:
The method's class, javax.persistence.Table, is available from the following locations:jar:file:/F:/jdk/jre/lib/ext/servlet-api.jar!/javax/servlet/ServletContext.classjar:file:/C:\Users\fan\.m2\repository\javax\servlet\javax.servlet-api\3.1.0\javax.servlet-api-3.1.0.jar!/javax/servlet/ServletContext.class
大致是说本地有两个javax.servlet-api.jar 库, 而项目启动时使用了错误的那个库,导致找不到对应方法。解决办法就是删掉一个。
因为我的项目是基于maven的,所以项目应该使用maven下载的jar,F盘的那个显然是不需要的(maven下载的jar包默认存放位置为c盘user目录下的.m2文件夹内),所以删除掉F:/jdk/jre/lib/ext/servlet-api.jar就搞定了。
ps:如果是环境用的是idea,可能需要先关闭idea才能删除目标jar包
联系客服