From 347c2bf9db8a7c3e510b9726f81138b938dd9c78 Mon Sep 17 00:00:00 2001 From: Calvin Ken <2993614148@qq.com> Date: Mon, 9 Jul 2018 18:07:35 +0800 Subject: [PATCH] Solve the error "Unable to find @SpringBootConfiguration when doing @WebMvcTest for Spring Controller" --- springboot-restdocs/src/test/java/com/forezp/WebLayerTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/springboot-restdocs/src/test/java/com/forezp/WebLayerTest.java b/springboot-restdocs/src/test/java/com/forezp/WebLayerTest.java index b72c99f..76a10ca 100755 --- a/springboot-restdocs/src/test/java/com/forezp/WebLayerTest.java +++ b/springboot-restdocs/src/test/java/com/forezp/WebLayerTest.java @@ -19,6 +19,7 @@ @RunWith(SpringRunner.class) @WebMvcTest(HomeController.class) +@ContextConfiguration(classes = {SpringbootRestdocsApplication.class}) @AutoConfigureRestDocs(outputDir = "target/snippets") public class WebLayerTest { @@ -31,4 +32,4 @@ public void shouldReturnDefaultMessage() throws Exception { .andExpect(content().string(containsString("Hello World"))) .andDo(document("home")); } -} \ No newline at end of file +}