gpt4 book ai didi

java - 编译 Maven 出现多个错误

转载 作者:行者123 更新时间:2023-12-02 01:36:49 26 4
gpt4 key购买 nike

我正在尝试在我的项目中使用 maven,但每次都会收到此错误,并且不知道如何修复它。

以下是我的所有设置:

Java 版本:

C:\Users\TomBo\Downloads\AnimalShelterJavaGUI>java -version
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

Maven 版本:

C:\Users\TomBo\Downloads\AnimalShelterJavaGUI>mvn -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-
10T17:41:47+01:00)
Maven home: C:\Users\TomBo\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-
0\183.5429.30\plugins\maven\lib\maven3\bin\..
Java version: 1.8.0_181, vendor: Oracle Corporation
Java home: C:\Program Files (x86)\Java\jdk1.8.0_181\jre
Default locale: nl_NL, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "x86", family: "dos"

Maven 编译:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building AnimalShelterJavaGUI 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @
AnimalShelterJavaGUI ---
[INFO] Deleting C:\Users\TomBo\Downloads\AnimalShelterJavaGUI\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @
AnimalShelterJavaGUI ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered
resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @
AnimalShelterJavaGUI ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252,
i.e. build is platform dependent!
[INFO] Compiling 14 source files to
C:\Users\TomBo\Downloads\AnimalShelterJavaGUI\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.965 s
[INFO] Finished at: 2019-03-12T13:34:04+01:00
[INFO] Final Memory: 7M/20M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-
plugin:3.8.0:compile (default-compile) on project AnimalShelterJavaGUI:
Fatal error compiling: invalid flag: --module-path -> [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/MojoExecutionException

这是编译结果

我的JAVA_HOME目录:

enter image description here我的 POM.xml 文件:

<groupId>groupId</groupId>
<artifactId>AnimalShelterJavaGUI</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<openfxVersion>11.0.2</openfxVersion>
<codeVersion>11</codeVersion>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>${codeVersion}</release>
<source>${codeVersion}</source>
<target>${codeVersion}</target>
</configuration>
</plugin>
</plugins>
</build>

我想使用这个,因为我要和 Jenkins 一起工作。希望大家能帮帮我。

最佳答案

我猜您的 PATH 上的 JDK 错误,因为您的 java -version 显示 Java 8,而您尝试使用 Java 11 进行编译。

检查您的 PATH 变量。

关于java - 编译 Maven 出现多个错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55121484/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com