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

前端 未结 6 698
清歌不尽
清歌不尽 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:17

    This happens when your development and production environments are using different servlet API versions.

    While building with tomcat7(for example) it supports servlet 3 and hence you will not receive any error.

    While doing the same on a lower version tomcat, it will throw error.

    Solution:

    Either upgrade one of the environments to support servlet 3 or just downgrade your code to use servlet 2.5

提交回复
热议问题