【问题标题】:Fail to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile): Fatal error compiling: invalid target release: 11无法执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile): Fatal error compile: invalid target release: 11
【发布时间】:2021-10-19 03:30:32
【问题描述】:

我想构建项目,它给出了这样的错误:

无法执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project messing-utils-core:致命错误编译:无效的目标版本: 11

我尝试通过谷歌搜索以各种方式修复它,但它在我的本地不起作用。我正在使用 Eclipse。

这是我的 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">
    <parent>
        <groupId>sg.com.nets.utils</groupId>
    <artifactId>messaging-utils-parent</artifactId>
    <version>1.2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>messaging-utils-core</artifactId>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.junit.vintage</groupId>
                <artifactId>junit-vintage-engine</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-logging</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>sg.com.nets.common.faulttolerance</groupId>
        <artifactId>fault-tolerance-core</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-validation</artifactId>
    </dependency>
    <dependency>
        <groupId>com.solacesystems</groupId>
        <artifactId>sol-jcsmp</artifactId>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.qpid</groupId>
        <artifactId>qpid-jms-client</artifactId>
    </dependency>
</dependencies>

我运行 mvn --version 它给出了这个:

Apache Maven 3.6.3

Java version: 1.8.0_281

对于我的环境,我有这个:

JAVA_HOME = D:\pathlocation\jdk1.8.0_281

请帮助我,因为我已经尝试解决此问题几天但仍未解决。谢谢。

【问题讨论】:

    标签: maven pom.xml


    【解决方案1】:

    我已经解决了这个问题。我只是添加这个:

    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.0</version>
    <configuration>
        <source>1.8</source> 
        <target>1.8</target>
    </configuration>
    </plugin>
    

    【讨论】:

      【解决方案2】:

      您正在尝试使用 JDK 8 为 Java 11 构建项目。

      所以你需要使用更新的 JDK。

      【讨论】:

        猜你喜欢
        • 2017-02-18
        • 2020-05-10
        • 2022-01-04
        • 2019-04-09
        • 2018-03-04
        • 2016-08-06
        • 1970-01-01
        • 2021-03-11
        • 2020-03-24
        相关资源
        最近更新 更多