Spring boot: java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.getHttpServletMapping()Ljavax/servlet/http/HttpServletMapping;

后端 未结 5 2393
小鲜肉
小鲜肉 2020-12-10 03:44

When I run this application on built-in server or other tomcat server it gives me following error message. I am using jdk8, STS V-3.9.7. Can someone help me resolve it

5条回答
  •  被撕碎了的回忆
    2020-12-10 03:55

    I think there is a version mismatch (possibly a Bug?) in Spring Boot.

    Spring Boot 2.1.X uses Tomcat 9 which has the Servlet API v4.
    But Spring Boot Web 2.1.X still incorporates Servlet API v3.1.

    You should solve the problem by downgrading the spring-boot-starter-tomcat to version 2.0.X.

        
            org.springframework.boot
            spring-boot-starter-tomcat
            2.0.7.RELEASE
            test
        
    

    Edit:
    It might as well work just to change the Tomcat version property.

        
            8.5.37
        
    

提交回复
热议问题