0

我使用 Junit4 配置了我的其余文档,使用 spring boot 1.4

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@WebAppConfiguration
@ActiveProfiles(SPRING_PROFILE_ACTIVE_TEST)
public class CustomerDetailsControllerWACTest {

    @Autowired
    private WebApplicationContext  wac;


    @Rule
    public final JUnitRestDocumentation documentation =
            new JUnitRestDocumentation("build/generated-snippets");

    private RestDocumentationResultHandler document;

    MockMvc mockMvc;


    @Before
    public void setUp() throws Exception
    {
        this.document = document("{method-name}", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()));


        this.mockMvc = MockMvcBuilders.webAppContextSetup(wac).
                apply(documentationConfiguration(this.documentation))
                .alwaysDo(this.document)
                .build();
    }

但错误是The method documentationConfiguration(RestDocumentation) in the type MockMvcRestDocumentation is not applicable for the arguments (JUnitRestDocumentation)

该文档也具有与此处提到的相同的配置。但仍然显示上述错误。

RestDocs 依赖项(版本):spring-restdocs-core-1.1.1 和 spring-restdocs-mockmvc-1.0.1

4

1 回答 1

2

You have incompatible version mismatch. You should use the same versions of core and mockmvc.

The JUnitRestDocumentation from spring-restdocs-core 1.1.1 cannot be applied to MockMvcRestDocumentation.documentationConfiguration(RestDocumentation) since that method in version 1.0.1 only accepts RestDocumentation. The overloaded method accepting the interface RestDocumentationContextProvider was added in 1.1.

于 2016-09-07T09:49:47.267 回答