zoukankan      html  css  js  c++  java
  • (default-compile) on project app: Fatal error compiling: 无效的标记: --release -> [Help 1]

    <plugins>
    <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>${maven-compiler-plugin.version}</version>
    <configuration>
    <release>8</release>
    </configuration>
    </plugin>
    </plugins>

    如果你的pom.xml文件如上所示,并且使用jdk8,则会报错

    (default-compile) on project app: Fatal error compiling: 无效的标记: --release -> [Help 1]

    查阅官方文档,release Java9才支持

    http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#release

    <release>

    The -release argument for the Java compiler, supported since Java9
    • Typejava.lang.String
    • Since3.6
    • RequiredNo
    • User Propertymaven.compiler.release

    解决办法,可以设计jdk版本到Java9+,或者更改maven-compiler-plugin配置

    参考如下

    <configuration>
    <source>${maven.compiler.source}</source>
    <target>${maven.compiler.target}</target>
    <compilerArguments>
    <bootclasspath>${java.home}/lib/rt.jar</bootclasspath>
    </compilerArguments>
    <encoding>${project.build.sourceEncoding}</encoding>
    <annotationProcessorPaths>
    <path>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>${lombok.version}</version>
    </path>
    </annotationProcessorPaths>
    </configuration>

    如果没有使用 projectlombok,只用这个配置

    <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>${maven-compiler-plugin.version}</version>
    <configuration>
    <source>${maven.compiler.source}</source>
    <target>${maven.compiler.target}</target>
    <compilerArguments>
    <bootclasspath>${java.home}/lib/rt.jar</bootclasspath>
    </compilerArguments>
    <encoding>${project.build.sourceEncoding}</encoding>
    </configuration>
    </plugin>
  • 相关阅读:
    AtCoder 杂题乱写
    JOISC2020 遗迹
    【考试总结】20220107
    AGC021F Trinity
    CCPC2021 广州A/CF Gym103415A
    【考试总结】20220115
    JDK8 时间api当天的开始和截至时间
    技术方案模板
    正则表达式
    组合算法
  • 原文地址:https://www.cnblogs.com/exmyth/p/14245134.html
Copyright © 2011-2022 走看看