SpringBoot项目编译报错——Fatal error compiling:无效的标记: --release -> [Help 1]

这篇具有很好参考价值的文章主要介绍了SpringBoot项目编译报错——Fatal error compiling:无效的标记: --release -> [Help 1]。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

一. 报错部分代码如下:

[INFO] --- maven-compiler-plugin:3.11.0:compile (default-compile) @ radiometer-management ---
[INFO] Changes detected - recompiling the module! :source
[INFO] Compiling 2 source files with javac [debug release 1.8] to target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.537 s
[INFO] Finished at: 2023-05-30T16:50:46+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project radiometer-management: Fatal error compiling: 无效的标记: --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

二. 报错原因排查

首先百度过之后知道要核查jdk版本。

1.pom.xml引用JDK版本。

<?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.1.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>radiometer-management</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>radiometer-management</name>
    <description>radiometer-management</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.oscar</groupId>
            <artifactId>oscarJDBC16</artifactId>
            <scope>system</scope>
            <systemPath>${project.basedir}/src/main/resources/lib/oscarJDBC16.jar</systemPath>
            <version>1.0</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>3.1.0</version>
            </plugin>
        </plugins>
    </build>

</project>

2.Maven引用的JDK版本

SpringBoot项目编译报错——Fatal error compiling:无效的标记: --release -> [Help 1],spring boot,java,spring,数据库

3.Maven使用的Java版本

SpringBoot项目编译报错——Fatal error compiling:无效的标记: --release -> [Help 1],spring boot,java,spring,数据库

三、发现项目的pom.xml文件里缺少插件的引用

加入以下代码。注:source和target要和引用的JDK统一版本,不然会报错。

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

四、重新编译项目,还是报错

主要错误如下所示:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project radiometer-management: Fatal error compiling: 无效的标记: --release -> [Help 1]

淦!设置了一圈怎么报错还是不变,这时候已经过去2小时,快崩溃了。期间经历了clean、reload,依然报同一个错误。网上的各种方法都试了。版本的统一也检查了800遍就是运行不成功。最后怀疑是不是某个版本号太高了,和JDK8不兼容,把

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.1.0</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

里的3.1.0改成了2.7.3。点击reload project。重新运行项目,希望这次不会出错了呀!

五、终于

还是报错!!!只不过这次换了个错误,表示真的是因为前面引用的版本号太高了导致上一个错误。新的错误是什么呢?

org/springframework/boot/maven/RepackageMojo has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0

?这是什么鬼,让我们翻译一下:

org/springframework/boot/maven/RepackageMojo是由较新版本的Java Runtime(类文件版本61.0)编译的,该版本的Java运行时只能识别52.0以下的类文件版本

没办法了,距离成功只差一步,继续善用网络。先是查询了错误中提到的类文件版本61.0,发现一个对应关系如下表:

49 = Java 5
50 = Java 6
51 = Java 7
52 = Java 8
53 = Java 9
54 = Java 10
55 = Java 11
56 = Java 12
57 = Java 13
58 = Java 14

由此可以推断出编译时用到的类文件版本61对应的是Java 17,可是系统中只识别到了Java8,可是我也没设置过Java17呀,为什么用这个版本编译?
终于发现是因为之前用的spring-boot版本太高了,也需要修改。

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>2.3.3.RELEASE</version>
</plugin>

将3.1.0降为2.3.3.RELEASE。点击右侧Maven—Lifecycle—clean。
右击项目,选择Maven—Reload project。等待下载2.3.3版本。完成后重新运行项目——成功!!!
SpringBoot项目编译报错——Fatal error compiling:无效的标记: --release -> [Help 1],spring boot,java,spring,数据库文章来源地址https://www.toymoban.com/news/detail-594779.html

到了这里,关于SpringBoot项目编译报错——Fatal error compiling:无效的标记: --release -> [Help 1]的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • QT使用MSVC编译器报错:Project ERROR: Cannot run compiler ‘cl‘以及后续问题解决

    记录一次qtcreator工程使用MSVC创建报错“ Project ERROR: Cannot run compiler ‘cl’ ”,没办法运行编译器cl。 只显示 qmake配置文件 不出现工程文件, 在qtcreator安装目录下的MSVC2017确实并未找到cl.exe文件,于是下载了everything搜索软件,在电脑上找到了VSstudio的安装目录下MSVC2017编译器下

    2024年02月05日
    浏览(47)
  • springboot项目编译提示无效的源发行版17解决

    说明:本地机版本jdk为1.8,编码项目的时候提示无效的源发行版17。 1.修改项目设置:jdk版本为8     2.修改系统设置 3.pom检查是否jdk版本为1.8 如上修改完成后应该会解决问题,但是我本地还是报如此错误。然后检查一圈下来,我默认创建的spring版本为3.0,而3.0的默认依赖jd

    2024年02月11日
    浏览(35)
  • 【RUST】mac m1编译rust项目失败: could not compile `` due to previous error

    2.1 查看clang: 结果如下: 2.2 查看llvm-ar: 结果如下: 2.3 如果没有安装llvm-ar,安装命令如下: 2.4 查看是否安装成功命令: 结果如下: 2.5 重新执行cargo 命令: 执行cargo clean: 执行一次带AR参数的cargo命令(本人执行一次就好了): 如果没有没有报错, 后续就可以使用正常的

    2024年02月07日
    浏览(39)
  • LLVM编译报错解决:collect2: fatal error: ld terminated with signal 9 [Killed]

    克隆代码到本地 配置编译选项 generator一般使用Ninja,而 options 中必须要传入的参数是构建类型 CMAKE_BUILD_TYPE 不同的CMAKE_BUILD_TYPE区别如下: Build Type Optimization Debug Info Assertion Release For Speed No No Debug None Yes Yes RelWithDebInfo For Speed Yes No MinSizeRel For Size No No Release适合LLVM和Clang的用户

    2024年02月11日
    浏览(26)
  • idea编译maven项目报错:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile

    创建了一个maven工程,编译时报错 Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project mybatisplus: Fatal error compiling: 无效的标记: --release - [Help 1] 项目中maven-plugin版本不匹配。我的IDEA版本2023.2.3,JDK版本为1.8.我是把自己的maven版本降低到3.5.1,编

    2024年02月05日
    浏览(43)
  • fatal error: linux/compiler-gcc9.h: No such file or directory

    linux 找到README文件 mzh@DESKTOP-GITL67P:~$ gcc --version gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   因为当前gcc版本是9.x, 找不到 compiler-gcc

    2024年02月09日
    浏览(40)
  • UE4/5关于数字人MetaHuman打包项目后,打开游戏发生的关于Assertion failed: CastResult或者fatal error报错

    目录 笔者的打包经历 该方法不一定成功,但总得试试。 解决方法: 本来笔者因为各种各样的盗版原因,打算将本文放置在VIP的,但考虑到广大人士可能和笔者一样发生这种问题而无法解决,便决定还是开把伞。 Assertion failed: CastResult或者fatal error的报错是在打包成功后,再

    2024年02月15日
    浏览(92)
  • 合约编译solc.compile()时报错‘{“errors”:[{“component”:“general”,“formattedMessag

    1.首先编译脚本是: 此时输出 compileResult会报错: ‘{“errors”:[{“component”:“general”,“formattedMessage”:\\\"* Line 1, Column 2n Syntax error: value, object or array expected.n* Line 1, Column 3n Extra non-whitespace after JSON value.n\\\",“message”:\\\"* Line 1, Column 2n Syntax error: value, object or array expected.n* Lin

    2024年02月10日
    浏览(24)
  • SpringBoot 的项目编译即报错处理--JSB系列之001

      SpringBoot知识范围-学习步骤【JSB系列之000】 ---总目录 SpringBoot 的项目编译即报错处理--JSB系列之001 SpringBoot 的项目helloworld--JSB系列之002 SpringBoot 的配置类--JSB系列之003 SpringBoot 的项目如何运行--JSB系列之004 SpringBoot操作数据库JdbcTemplate--JSB系列之005 SpringBoot操作数据库jpa--JSB系

    2024年02月16日
    浏览(25)
  • SpringBoot 的项目编译即报错处理--SB系列之001

      SpringBoot知识范围-学习步骤【JSB系列之000】 ---总目录 SpringBoot 的项目编译即报错处理--JSB系列之001 SpringBoot 的项目helloworld--JSB系列之002 SpringBoot 的配置类--JSB系列之003 SpringBoot 的项目如何运行--JSB系列之004 SpringBoot操作数据库JdbcTemplate--JSB系列之005 SpringBoot操作数据库jpa--JSB系

    2024年02月16日
    浏览(29)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包