Org.Junit 在 Spring 引导版本 2.3 中未解决
Org.Junit is unresolved in Spring boot version 2.3
我创建了一个 SPRING BOOT 应用程序版本 2.3.2,当我尝试使用 JUNIT 5 编写单元测试时。STS IDE 中的单元测试 class 显示 org.junit 未解决。
这是我对 build.gradle
的依赖
dependencies {
compile "org.springframework.boot:spring-boot-starter-actuator:2.3.2.RELEASE"
compile "org.springframework.boot:spring-boot-starter-web:2.3.2.RELEASE"
compile "org.springframework.boot:spring-boot-starter-log4j2:2.3.2.RELEASE"
testCompile "org.springframework.boot:spring-boot-starter-test:2.3.2.RELEASE"
}
测试Class:
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
class PasswordvaultComponentTest {
@Test void test()
{
fail("Not yet implemented");
}
}
因为 JUNIT JUPITER 已经捆绑到 SPRING BOOT 2.3.2 中。我不需要在 gradle 中显式提供 Junit Jupiter 依赖项。我在这里缺少任何其他配置吗?非常感谢任何帮助。
我在包裹 src/main/java 中进行了测试 class。所以我将我的测试 class 移动到包 src/test/java 并解决了依赖关系。
我创建了一个 SPRING BOOT 应用程序版本 2.3.2,当我尝试使用 JUNIT 5 编写单元测试时。STS IDE 中的单元测试 class 显示 org.junit 未解决。 这是我对 build.gradle
的依赖dependencies {
compile "org.springframework.boot:spring-boot-starter-actuator:2.3.2.RELEASE"
compile "org.springframework.boot:spring-boot-starter-web:2.3.2.RELEASE"
compile "org.springframework.boot:spring-boot-starter-log4j2:2.3.2.RELEASE"
testCompile "org.springframework.boot:spring-boot-starter-test:2.3.2.RELEASE"
}
测试Class:
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
class PasswordvaultComponentTest {
@Test void test()
{
fail("Not yet implemented");
}
}
因为 JUNIT JUPITER 已经捆绑到 SPRING BOOT 2.3.2 中。我不需要在 gradle 中显式提供 Junit Jupiter 依赖项。我在这里缺少任何其他配置吗?非常感谢任何帮助。
我在包裹 src/main/java 中进行了测试 class。所以我将我的测试 class 移动到包 src/test/java 并解决了依赖关系。