注意:由于我在my original question中给出了错误的答案,因此我不再受到任何关注。我知道程序员的想法:他们会在我的问题中看到“ 1个答案”,甚至不会公开。不要怪我,我该怎么办?我仍然没有找到解决这个问题的方法:(
当我尝试使用maven,java模块和junit 5运行一个简单项目时,出现以下错误消息:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project echo: Compilation failure: Compilation failure:
[ERROR] /C:/Users/andre/eclipse-workspace/echo/src/main/java/module-info.java:[2,35] module not found: org.junit.jupiter.engine
[ERROR] /C:/Users/andre/eclipse-workspace/echo/src/main/java/module-info.java:[3,35] module not found: org.junit.jupiter.api
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
这是我的目录结构:
echo
----src/main/java
--------com.udp.echo
------------App.java
------------EchoClient.java
------------EchoServer.java
--------module-info.java
----src/test/java/com.udp.echo
--------EchoTest.java
----pom.xml
这是我的module-info.java文件:
open module echo {
requires junit;
}
我实际上试图做require org.junit.jupiter.api
和require org.junit.jupiter.engine
,但这不会改变结果。
这是我的pom.xml
<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.udp</groupId>
<artifactId>echo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>echo</name>
<url>http://maven.apache.org</url>
<properties>
<java.version>12</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.4.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.4.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version>
</plugin>
</plugins>
</build>
</project>
这是运行mvn -v
的结果:
$ mvn -v
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T16:00:29-03:00)
Maven home: C:\apache-maven-3.6.1
Java version: 12.0.1, vendor: Oracle Corporation, runtime: C:\java\jdk-12.0.1
Default locale: pt_BR, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Maven是否不应该从Maven存储库下载其依赖项?如果是这样,为什么它抱怨找不到模块?这对我来说毫无意义。
我想念什么?