0

I am trying to generate a Rest API documentation based on spring-restdocs

In following code I am getting a compile time error at apply()

The method apply(RestDocumentationMockMvcConfigurer) is undefined for the type DefaultMockMvcBuilder

@ContextConfiguration(locations = { "classpath:/testApplicationRestService.xml" })
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
public class CustomerControllerTest {

    @Rule
    public final RestDocumentation restDocumentation = new RestDocumentation(
            "build/generated-snippets");

    @Autowired
    private WebApplicationContext context;
    private MockMvc mockMvc;

    @Before
    public void setUp() {

        this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
                .apply(documentationConfiguration(this.restDocumentation))
                .build();
    }

}
Vijay Kumar Rajput
  • 1,071
  • 1
  • 10
  • 30

1 Answers1

2

Spring REST Docs requires Spring Franework 4.1 or later. The apply method is new in Spring Framework 4.1. The compile failure means that you have an earlier version on the classpath. You should update your pom.xml or build.gradle to ensure that you're using the required version.

Andy Wilkinson
  • 108,729
  • 24
  • 257
  • 242