测试springboot项目出现Test Ignored的解决
测试springboot项目出现Test Ignored
今天在写springBoot项目运行测试类时出现了以下问题:
Test ignored.
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=…) with your test

原因是我在建包时把启动类放到了servlet包下,如图

需要把这个启动目录放到根目录下,移出来问题就解决了
测试类不报错只提示Test ignored的解决
在点击运行测试方法后出现如下错误:

解决方法:
在这个位置需要有一个Java类,名字可以随便写。

类里面这样写:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class MyApp {
public static void main(String[] args) {
SpringApplication.run(MyApp.class);//MyApp为你的启动类的名称 如下图
}
}

这相当于一个程序的入口,名字可以随便起,但是一定得有。
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
详谈java编码互转(application/x-www-form-urlencoded)
下面小编就为大家带来一篇详谈java编码互转(application/x-www-form-urlencoded)。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧2017-07-07
Springboot容器级后置处理器BeanDefinitionRegistryPostProcessor
这篇文章主要介绍了Springboot容器级后置处理器BeanDefinitionRegistryPostProcessor,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习吧2023-01-01


最新评论