当我尝试在我的系统中使用Java 17运行以下pom.xml时,我遇到了以下错误,当运行mvn clean install
时,我在IntelliJ软件中遇到了以下错误:
- 酒店马奎斯酒店**
Latitude-3420:~/TelegramWeb$ java -version
openjdk version "17.0.9" 2023-10-17
OpenJDK Runtime Environment (build 17.0.9+9-Ubuntu-120.04)
OpenJDK 64-Bit Server VM (build 17.0.9+9-Ubuntu-120.04, mixed mode, sharing)
Latitude-3420:~TelegramWeb$ mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.example:TelegramWeb >-----------------------
[INFO] Building TelegramWeb 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.3.2:clean (default-clean) @ TelegramWeb ---
[INFO] Deleting /home/TelegramWeb/target
[INFO]
[INFO] --- maven-resources-plugin:3.3.1:resources (default-resources) @ TelegramWeb ---
[INFO] Copying 1 resource from src/main/resources to target/classes
[INFO] Copying 0 resource from src/main/resources to target/classes
[INFO]
[INFO] --- maven-compiler-plugin:3.11.0:compile (default-compile) @ TelegramWeb ---
[INFO] Changes detected - recompiling the module! :source
[INFO] Compiling 1 source file with javac [debug release 17] to target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.824 s
[INFO] Finished at: 2023-12-18T04:39:45+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project TelegramWeb: Fatal error compiling: invalid flag: --release -> [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
字符串
下面给出的是我正在尝试'mvn clean install'的POM.XML。
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>3.2.0</version>
<relativePath/>
</parent>
<groupId>com.example</groupId>
<artifactId>TelegramWeb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>TelegramWeb</name>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
型
我还补充了以下内容:
<properties>
<java.version>17</java.version>
<maven.compiler.release>17</maven.compiler.release>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
型
和
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<release>17</release>
</configuration>
</plugin>
</plugins>
</build>
型
但是错误仍然存在。请帮助。
1条答案
按热度按时间5q4ezhmt1#
终端有自己的环境,在IntelliJ中,在命令提示符下执行
mvn -v
,查看你当前Maven使用的Java版本,我复制了你的pom.xml文件,执行了和你一样的错误,之后,我执行了mvn -v命令,发现Maven使用的是Java 1.8。我发现我设置了一个JAVA_HOME和一个JAVA_HOME_环境变量中有17,我删除了1.8版本,只剩下17版本,重启IntelliJ后,在终端执行mvn -v
,变成17.0.9,然后执行mvn clean install
,结果是BUILD SUCCESS。