Spring Cloud (4) | NoSuchMethodError:javax.servlet.ServletContext.getVirtualServerName()
来源:互联网 发布:舞蹈mmd软件 编辑:程序博客网 时间:2024/06/08 20:10
the method getVirtualServerName
has been added in ServletContext in Servlet 3.1. Find the java doc’s method getVirtualServerName
this problem can have at least 3 causes:
your servlet version is older that 3.1.
other jar has the servlet older version than 3.1.
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.
<dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> </dependency>
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:
<dependency> <groupId>org.apache.santuario</groupId> <artifactId>xmlsec</artifactId> <version>1.4.3</version> </dependency>
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:
<!-- exclude servlet-api 2.3 jar--> <dependency> <groupId>org.apache.santuario</groupId> <artifactId>xmlsec</artifactId> <version>1.4.3</version> <exclusions> <exclusion> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> </exclusion> </exclusions> </dependency> <!-- servlet-api 3.1 version has getVirtualServerName() --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> </dependency>
III. spring boot run the default tomcat 7. so define your tomcat version 8 instead of tomcat 7. so add the code your pom.xml:
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> <tomcat.version>8.5.5</tomcat.version> </properties>
原文链接:https://stackoverflow.com/questions/34950164/getting-nosuchmethoderrorjavax-servlet-servletcontext-getvirtualservername/47503564#47503564
- Spring Cloud (4) | NoSuchMethodError:javax.servlet.ServletContext.getVirtualServerName()
- NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String
- NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String
- java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
- java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()
- java.lang.NoSuchMethodError: javax.servlet.ServletContext.getEffectiveSessionTrackingModes()
- java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()
- java.lang.NoSuchMethodError: javax.servlet.ServletContext
- java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()
- java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String;
- java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String;
- java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String;
- java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String;
- java.lang.NoSuchMethodError: javax.servlet.ServletContext.getClassLoader()Ljava/lang/ClassLoader;
- NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String
- jfinal 报异常:java.lang.NoSuchMethodError: javax.servlet.ServletContext.getJspConfigDescriptor
- java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String;
- java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String;
- 怎么修改eclipse及jsp的编码
- 一直程序员的养成日记 第一章 第五节 识好文,转好文
- java代码请求URL
- 远观数据库设计
- Qt 中自定义QLabel上的点击事件
- Spring Cloud (4) | NoSuchMethodError:javax.servlet.ServletContext.getVirtualServerName()
- css3用户界面
- 欢迎使用CSDN-markdown编辑器
- java网络编程之Netty实战心跳检测(八)
- ZooKeeper 基础知识、部署
- 如何优雅的添加MGR节点?
- java获取系统属性
- 【Java】错误解决笔记
- STL之算术与集合