我使用 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