spring boot java.lang.NoSuchMethodError: javax.servlet.ServletContext.addServlet
在spring boot 环境中加启动时,出现如下异常:
nable to start embedded container; nested exception is java.lang.NoSuchMethodError: javax.servlet.ServletContext.addServlet(Ljava/lang/String;Ljavax/servlet/Servlet;)Ljavax/servlet/ServletRegistration$Dynamic;
解决方案:
经过检查是由于 servlet-api.jar 冲突导致,取消servlet-api.jar 导入
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>