java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.isAsyncStarted() while using Mockito with Junit

前端 未结 6 704
清歌不尽
清歌不尽 2020-12-20 13:48

I am trying to get my feet wet with TDD. I am trying to write unit test cases for controllers using Mockito in conjunction with MockMvc and Junit.

But I am getting a

6条回答
  •  长情又很酷
    2020-12-20 14:11

    Error message indicates that you have wrong version of Servlet API in your classpath.

    If you are using Gradle the execute

    gradle dependencies
    

    analyze the dependency tree and exclude the 'servlet-api' dependencies with version less than 3.0. You can do the following to exclude

    compile ('javax.servlet:jsp-api:2.0'){
        exclude module : 'servlet-api'
    }
    

    There can be multiple dependencies which further include servlet-api-2.x. Exclude all those

提交回复
热议问题