Spring-Boot-Starter-Data-MongoDB版本问题

发布于 2025-02-08 10:00:43 字数 2418 浏览 2 评论 0原文

引起的是:java.lang.unsupportedClassversionError:org/bson/codecs/record/record/recordcodecprovider已由Java Runtime的最新版本(类文件版本61.0)编译,此版本的Java Runtime仅识别类文件版本59.0 at Java.base/java.lang.classloader.defineclass1(本机方法)〜[na:na]

添加 pom.xml中的弹簧启动启动data-mongodb解决问题

4.0.0 com.infinira.fps FPS-API 0.0.1-snapshot 财务计划系统 财务计划系统API

<parent>
    <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-test -->
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.7.0</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <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>
    <dependency>
        <groupId>org.junit.vintage</groupId>
        <artifactId>junit-vintage-engine</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-log4j2</artifactId>
    </dependency>

</dependencies>

<properties>
    <java.version>1.8</java.version>
</properties>

Caused by: java.lang.UnsupportedClassVersionError: org/bson/codecs/record/RecordCodecProvider 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 59.0
at java.base/java.lang.ClassLoader.defineClass1(Native Method) ~[na:na]

Adding
spring-boot-starter-data-mongodb in pom.xml casuing the issues

4.0.0
com.infinira.fps
fps-api
0.0.1-SNAPSHOT
Financial planning system
Financial planning system API

<parent>
    <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-test -->
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.7.0</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <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>
    <dependency>
        <groupId>org.junit.vintage</groupId>
        <artifactId>junit-vintage-engine</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-log4j2</artifactId>
    </dependency>

</dependencies>

<properties>
    <java.version>1.8</java.version>
</properties>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

万劫不复 2025-02-15 10:00:43

UndubportedClassversionError意味着您的JRE比创建您要使用的类文件的版本更古老。
61表示Org/Bson/codecs/record/Record/Record Codecprovider已与JDK 17编译,而59表示您正在尝试使用JRE 15来运行这些类文件。

您可以尝试找到已与JDK 15或以上编译的Org/bson/codecs/record/Record Codecprovider的较旧版本,请自己编译来源(前提是它们不使用比JDK 15更新的功能)或将您的JRE升级到17。

由于对JDK 15的积极支持可能已经结束了一年多以前(OpenJDK,其他口味可能会有所不同),而JDK 17是LTS,并将得到支持,直到2027年(再次是OpenJDK),我建议我升级到JRE 17 17 。

UnsupportedClassVersionError means that your JRE is older than the version that created the class files you are trying to use.
61 means that org/bson/codecs/record/RecordCodecProvider has been compiled with JDK 17 while 59 means that you are trying to use JRE 15 to run these class files.

You could either try to find an older version of org/bson/codecs/record/RecordCodecProvider that has been compiled with JDK 15 or older, try to compile the sources yourself (provided they do not use any features newer than JDK 15), or upgrade your JRE to 17.

As active support for JDK 15 may have ended more than a year ago (OpenJDK, other flavours may vary), while JDK 17 is LTS and will be supported until 2027 (again OpenJDK) I recommend upgrading to JRE 17.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文