简体   繁体   中英

Spring Mock mvc rest-assured test fails to get status

Getting error while trying to test while running RestAssuredMockMvc and Spring:

INFO - Mapped "{[/mysql/hello],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String ee.t.mysql.controllers.testController.printHello()
INFO - HV000001: Hibernate Validator 5.1.2.Final
INFO - Looking for @ControllerAdvice: org.springframework.test.web.servlet.setup.StubWebApplicationContext@4d7cca20
INFO - Initializing Spring FrameworkServlet ''
INFO - FrameworkServlet '': initialization started
INFO - FrameworkServlet '': initialization completed in 6 ms

java.lang.NoSuchMethodError: javax.servlet.http.HttpServletResponse.getStatus()I
    at org.springframework.web.servlet.FrameworkServlet.publishRequestHandledEvent(FrameworkServlet.java:1066)

UPDATE:

fixed by changing version to 3.x:

 <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>

This is 99% a dependency issue. One of your jars is clashing with another version of the same jar and probably related to a servlet dependency. Can you share your pom.xml?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM