Spring Cloud (4) | NoSuchMethodError:javax.servlet.ServletContext.getVirtualServerName()
发布日期:2021-06-30 12:19:18 浏览次数:2 分类:技术文章

本文共 1597 字,大约阅读时间需要 5 分钟。

the method getVirtualServerName has been added in ServletContext in Servlet 3.1. Find the java doc’s method

this problem can have at least 3 causes:

  1. your servlet version is older that 3.1.

  2. other jar has the servlet older version than 3.1.

  3. your tomcat version is older than 8

to solve it, you can try the below way.

I. to check your pom.xml whether there are the below code.

javax.servlet
javax.servlet-api
3.1.0

if your pom.xml has the above code, it would still has that problem. you can do the second way.

II. to check your other jar has refer to the javax.servlet-api jar. for example, the org.apache.santuario has refer to the javax.servlet-api jar. the pom.xml:

org.apache.santuario
xmlsec
1.4.3

but when you look at the maven dependencies, it refer to the javax.servlet-api jar whose version is 2.3 older than 3.1.

so you should exclude the 2.3 version. pom.xml:

org.apache.santuario
xmlsec
1.4.3
javax.servlet
servlet-api
javax.servlet
javax.servlet-api
3.1.0

III. spring boot run the default tomcat 7. so define your tomcat version 8 instead of tomcat 7. To add the code your pom.xml:

UTF-8
UTF-8
1.8
8.5.5

原文链接:

在这里插入图片描述

更多系列文章推荐:

转载地址:https://java-basketball.blog.csdn.net/article/details/78643626 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:java.io.FileNotFoundException: class path resource [templates/] spring-cloud-netflix-eureka-server
下一篇:Spring Cloud (7) | Mongodb 微服务

发表评论

最新留言

第一次来,支持一个
[***.219.124.196]2024年04月12日 12时56分17秒