错误复现 我的代码结构 test代码
@SpringBootTest
public class test {
@Autowired
RestHighLevelClient highLevelClient;
@Test
public void test1(){
System.out.println(highLevelClient);
}
}
报错:
Test ignored.
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
原因: 找不到启动类。 建立与项目目录同级别的类,然后进行测试 项目结构
@SpringBootTest
public class TestApplication {
}
@SpringBootTest
public class test {
@Autowired
RestHighLevelClient highLevelClient;
@Test
public void test1(){
System.out.println(highLevelClient);
}
}
成功!
|