springboot 使用test时 注解@RunWith不存在的解决方法:
将pow文件中的依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
改为:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
本文介绍了解决SpringBoot项目中使用@RunWith注解进行单元测试时出现的问题的方法。通过调整pom.xml文件中spring-boot-starter-test依赖的配置,移除junit-vintage-engine排除项,确保测试框架正常运行。
4891

被折叠的 条评论
为什么被折叠?



