簡體   English   中英

Z32F72222026696F3078889194DEE83E5Z Z581D6381D6381F35E4F9D77201ACF87B364Z版本2019-09 ZE1E1E1E1E1E1E1E1E1E1D3D3D3D4127E9EENENC127E0480C12121280C.14C.FAF12.14CAF14.CAF14.CAF1(4.CAF1)

[英]Eclipse IDE version 2019-09 R (4.13.0) does not recognize Maven dependencies

我的版本 Eclipse

Eclipse IDE for Enterprise Java Developers.
Version: 2019-09 R (4.13.0)
Build id: 20190917-1200
OS: Windows 10, v.10.0, x86_64 / win32
Java version: 13.0.1

我創建了一個 Java 應用程序有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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>junit5_sample</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.6.0-M1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.6.0-M1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>8</source>
                    <target>8</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.10</version>
            </plugin>            
        </plugins>
    </build>
</project>

樣品 class

package com.sample.junit5;

import static org.junit.jupiter.api.Assertions.fail;

public class StringTest {

    @Test
    void test() {
        fail("Not yet implemented");
    }

}

but Eclipse IDE version 2019-09 R (4.13.0) does not recognize Maven dependencies

在此處輸入圖像描述

如何解決?

Junit 依賴項在您的 pom.xml 的測試 scope 中聲明(如預期的那樣),因此您的測試類必須位於 test 文件夾/main/src.test 中:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM