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>

 

posted @ 2021-10-31 22:36  Vincent-yuan  阅读(131)  评论(0编辑  收藏  举报