Getting NoSuchMethodError:javax.servlet.ServletContext.getVirtualServerName()

在用springboot做接口开发时,遇到一个问题:Getting NoSuchMethodError:javax.servlet.ServletContext.getVirtualServerName()

原因是:

getVirtualServerName 方法是在 servlet3.1之后引入的,需要把 servlet-api 3.1之前的版本排除掉,引入3.1之后的版本。

  <dependency>
       <groupId>javax.servlet</groupId>
       <artifactId>javax.servlet-api</artifactId>
       <version>3.1.0</version>
    </dependency>
原文地址:https://www.cnblogs.com/Vincent-yuan/p/15491489.html