我正在尝试基于弹簧restdocs生成Rest文档。
在下面的代码中,我在apply()上得到了一个编译时错误
方法应用(RestDocumentationMockMvcConfigurer)未定义为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();
}
}发布于 2015-10-11 21:35:50
Spring文档需要SpringFranework4.1或更高版本。apply方法是SpringFramework4.1中的新方法。编译失败意味着您在类路径上有一个早期版本。您应该更新您的pom.xml或build.gradle,以确保您正在使用所需的版本。
https://stackoverflow.com/questions/33052007
复制相似问题