Spring Boot

SpringBoot —程序包org.springframewo

2021-04-25  本文已影响0人  少缶

一. 遇到问题 :程序包org.springframework.boot.test.context不存在


发生错误的原因是项目中缺少spring-boot-starter-test依赖导致的,解决方案如下:
1. Maven管理:

在项目根目录的pom.xm文件中的<dependencies>节点下增加以下依赖即可:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
</dependency>
2. Gradle管理:

在项目的src目录的build.gradle.kts文件中,找到dependencies增加以下依赖即可:

testImplementation("org.springframework.boot:spring-boot-starter-test")

二. 遇到问题 :程序包org.junit.jupiter.api不存在


发生错误的原因是和问题一org.springframework.boot.test.context不存在的是一样的,都是因为缺少spring-boot-starter-test依赖导致的,解决方案同上。
上一篇 下一篇

猜你喜欢

热点阅读