打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
解决javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;

以下方法适用于基于spring boot的应用

先看以下报错信息:

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包

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String
javax.servlet.jsp.tagext.TagAttributeInfo.<init>(Ljava/lang/String;ZLjava/lang/String;ZZ)V
Servlet技术(上)
异常:java.lang.NoSuchMethodError: javax.servlet.jsp.JspFactory.getJspApplicationContext
文件下载(只需要简单的四步),Java中都通用
在Eclipse中添加Servlet
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服