错误:(3, 29) java: 程序包org.junit.jupiter.api不存在
跟着视频学的做的,改过maven版本,换过jar包的版本,代码本身没有报错,一运行就报错,CSDN上能搜到的解决方法都用到过,还是无法解决
依赖版本不对,导入的包正常应该是org.junit.Test
貌似你的包不对。
依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
引用:
import org.junit.Test;
重新加载maven包
你引入的包和测试类有问题,参考下图,pom文件添加junit依赖,同时test类添加注解
单元测试不应该是这个包,换一个,然后加上该有的注解,就可以了
改一下依赖版本:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.0.7.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
@Test 引入的包不对
import org.junit.Test
先把仓库里面的相应包删了再重新导