无法在Sping Boot 2.7.0中找到org.junit.测试

xytpbqjk  于 2022-11-11  发布在  其他
关注(0)|答案(1)|浏览(230)

我无法找到org.junit.Test在Spring Boot 2.7.0我正在使用eclipse和当我按下ctrl+空格后写@测试,我可以看到唯一的选项导入是org.junit.jupiter.api.Test如下面的屏幕截图所示。

2.7.0不支持org.junit.Test了吗?
下面的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.0</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.rishi</groupId>
    <artifactId>BasicSpringExample</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>BasicSpringExample</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
3ks5zfa0

3ks5zfa01#

旧的org.junit包用于JUnit 4.x。
新得org.junit.jupiter.api包适用于JUnit 5.x.
您应该更喜欢5.x。JUnit 4.x在这一点上是旧的。

相关问题