测试springboot项目出现Test Ignored的解决
作者:我长不高了啊 时间:2022-06-25 08:37:02
测试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为你的启动类的名称 如下图
}
}
这相当于一个程序的入口,名字可以随便起,但是一定得有。
来源:https://blog.csdn.net/weixin_45852687/article/details/118879791
标签:测试,springboot,Test,Ignored
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
C#编程中常见数据结构的比较(Unity3D游戏开发)
2022-01-02 06:58:03
hadoop实现grep示例分享
2023-12-24 05:31:04
详解SpringBoot获得Maven-pom中版本号和编译时间戳
2022-11-27 19:45:27
![](https://img.aspxhome.com/file/2023/6/91476_0s.png)
Spring Boot实现发送邮件
2023-11-08 22:19:40
![](https://img.aspxhome.com/file/2023/3/91543_0s.jpg)
Android实现APP秒表功能
2022-11-13 13:58:26
![](https://img.aspxhome.com/file/2023/8/95988_0s.jpg)
Mybatis代码生成器Mybatis Generator(MBG)实战详解
2023-12-02 23:04:31
![](https://img.aspxhome.com/file/2023/1/73031_0s.jpg)
Java字符串技巧之删除标点或最后字符的方法
2023-02-06 21:42:50
Java 接口和抽象类的区别详解
2021-07-26 13:30:21
浅谈@RequestMapping注解的注意点
2023-07-11 02:12:39
C# datagrid非常规方法实现添加合并列
2023-02-08 07:31:00
![](https://img.aspxhome.com/file/2023/3/71743_0s.jpg)
Java实现文件和base64流的相互转换功能示例
2023-11-18 07:45:01
Spring集成Swagger常见错误及解决办法
2023-07-10 05:01:17
![](https://img.aspxhome.com/file/2023/9/88749_0s.png)
Java 网络编程总结
2023-11-10 22:19:29
![](https://img.aspxhome.com/file/2023/1/59071_0s.png)
seata-1.4.0安装及在springcloud中使用详解
2023-02-21 00:49:21
![](https://img.aspxhome.com/file/2023/5/62835_0s.png)
Spring Boot启动过程全面解析(三)
2023-09-13 13:16:39
详解java Collections.sort的两种用法
2023-11-28 09:30:31
![](https://img.aspxhome.com/file/2023/3/60473_0s.png)
用Java实现24点游戏
2022-07-18 20:56:14
![](https://img.aspxhome.com/file/2023/1/63481_0s.png)
解决RestTemplate第一次请求响应速度较慢的问题
2021-10-20 15:50:50
Spring之spring-context-indexer依赖详解
2023-11-23 12:21:41
![](https://img.aspxhome.com/file/2023/4/59024_0s.jpg)
老生常谈java中的fail-fast机制
2022-01-27 15:31:50