Intellij Idea Apache Maven plugins 3.11.0编译问题

ggazkfy8  于 2024-01-05  发布在  Apache
关注(0)|答案(1)|浏览(279)

当我尝试在我的系统中使用Java 17运行以下pom.xml时,我遇到了以下错误,当运行mvn clean install时,我在IntelliJ软件中遇到了以下错误:

  • 酒店马奎斯酒店**
  1. Latitude-3420:~/TelegramWeb$ java -version
  2. openjdk version "17.0.9" 2023-10-17
  3. OpenJDK Runtime Environment (build 17.0.9+9-Ubuntu-120.04)
  4. OpenJDK 64-Bit Server VM (build 17.0.9+9-Ubuntu-120.04, mixed mode, sharing)
  5. Latitude-3420:~TelegramWeb$ mvn clean install
  6. [INFO] Scanning for projects...
  7. [INFO]
  8. [INFO] ----------------------< com.example:TelegramWeb >-----------------------
  9. [INFO] Building TelegramWeb 0.0.1-SNAPSHOT
  10. [INFO] --------------------------------[ jar ]---------------------------------
  11. [INFO]
  12. [INFO] --- maven-clean-plugin:3.3.2:clean (default-clean) @ TelegramWeb ---
  13. [INFO] Deleting /home/TelegramWeb/target
  14. [INFO]
  15. [INFO] --- maven-resources-plugin:3.3.1:resources (default-resources) @ TelegramWeb ---
  16. [INFO] Copying 1 resource from src/main/resources to target/classes
  17. [INFO] Copying 0 resource from src/main/resources to target/classes
  18. [INFO]
  19. [INFO] --- maven-compiler-plugin:3.11.0:compile (default-compile) @ TelegramWeb ---
  20. [INFO] Changes detected - recompiling the module! :source
  21. [INFO] Compiling 1 source file with javac [debug release 17] to target/classes
  22. [INFO] ------------------------------------------------------------------------
  23. [INFO] BUILD FAILURE
  24. [INFO] ------------------------------------------------------------------------
  25. [INFO] Total time: 0.824 s
  26. [INFO] Finished at: 2023-12-18T04:39:45+05:30
  27. [INFO] ------------------------------------------------------------------------
  28. [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]
  29. [ERROR]
  30. [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
  31. [ERROR] Re-run Maven using the -X switch to enable full debug logging.
  32. [ERROR]
  33. [ERROR] For more information about the errors and possible solutions, please read the following articles:
  34. [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

字符串
下面给出的是我正在尝试'mvn clean install'的POM.XML。

pom.xml文件

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5. <parent>
  6. <groupId>org.springframework.boot</groupId>
  7. <artifactId>spring-boot-starter-parent</artifactId>
  8. <version>3.2.0</version>
  9. <relativePath/>
  10. </parent>
  11. <groupId>com.example</groupId>
  12. <artifactId>TelegramWeb</artifactId>
  13. <version>0.0.1-SNAPSHOT</version>
  14. <name>TelegramWeb</name>
  15. <properties>
  16. <java.version>17</java.version>
  17. </properties>
  18. <dependencies>
  19. <dependency>
  20. <groupId>org.springframework.boot</groupId>
  21. <artifactId>spring-boot-starter-data-mongodb</artifactId>
  22. </dependency>
  23. <dependency>
  24. <groupId>org.springframework.boot</groupId>
  25. <artifactId>spring-boot-starter-web</artifactId>
  26. </dependency>
  27. <dependency>
  28. <groupId>org.projectlombok</groupId>
  29. <artifactId>lombok</artifactId>
  30. <optional>true</optional>
  31. </dependency>
  32. <dependency>
  33. <groupId>org.springframework.boot</groupId>
  34. <artifactId>spring-boot-starter-test</artifactId>
  35. <scope>test</scope>
  36. </dependency>
  37. </dependencies>
  38. </project>


我还补充了以下内容:

  1. <properties>
  2. <java.version>17</java.version>
  3. <maven.compiler.release>17</maven.compiler.release>
  4. <maven.compiler.source>17</maven.compiler.source>
  5. <maven.compiler.target>17</maven.compiler.target>
  6. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  7. </properties>


  1. <build>
  2. <plugins>
  3. <plugin>
  4. <groupId>org.apache.maven.plugins</groupId>
  5. <artifactId>maven-compiler-plugin</artifactId>
  6. <version>3.11.0</version>
  7. <configuration>
  8. <release>17</release>
  9. </configuration>
  10. </plugin>
  11. </plugins>
  12. </build>


但是错误仍然存在。请帮助。

5q4ezhmt

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

相关问题