Unable to make field long java.nio.Buffer.address accessible:

复制代码
Caused by: java.lang.ExceptionInInitializerError: 
Exception java.lang.reflect.InaccessibleObjectException: 
Unable to make field long java.nio.Buffer.address accessible: 
module java.base does not "opens java.nio" to unnamed module @6bf256fa
复制代码
<?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">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>untitled1</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <!-- 添加 Netty 版本属性 -->
        <netty.version>4.1.77.Final</netty.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.apache.rocketmq</groupId>
            <artifactId>rocketmq-client</artifactId>
            <version>4.5.1</version>
            <!-- 排除旧版 Netty -->
            <exclusions>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-all</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- 添加兼容 JDK 17 的 Netty 版本 -->
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-all</artifactId>
            <version>${netty.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <mainClass>org.example.ConsumerExample</mainClass>
                    <arguments>
                        <argument>arg1</argument> <!-- 如果有命令行参数 -->
                    </arguments>
                    <!-- 添加 JVM 参数解决访问问题 -->
                    <jvmArgs>
                        <jvmArg>--add-opens</jvmArg>
                        <jvmArg>java.base/java.nio=ALL-UNNAMED</jvmArg>
                        <jvmArg>--add-opens</jvmArg>
                        <jvmArg>java.base/sun.nio.ch=ALL-UNNAMED</jvmArg>
                    </jvmArgs>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
相关推荐
Fireworkitte1 小时前
Apache POI 详解 - Java 操作 Excel/Word/PPT
java·apache·excel
weixin-a153003083161 小时前
【playwright篇】教程(十七)[html元素知识]
java·前端·html
DCTANT2 小时前
【原创】国产化适配-全量迁移MySQL数据到OpenGauss数据库
java·数据库·spring boot·mysql·opengauss
Touper.2 小时前
SpringBoot -- 自动配置原理
java·spring boot·后端
黄雪超2 小时前
JVM——函数式语法糖:如何使用Function、Stream来编写函数式程序?
java·开发语言·jvm
ThetaarSofVenice2 小时前
对象的finalization机制Test
java·开发语言·jvm
思则变2 小时前
[Pytest] [Part 2]增加 log功能
开发语言·python·pytest
lijingguang3 小时前
在C#中根据URL下载文件并保存到本地,可以使用以下方法(推荐使用现代异步方式)
开发语言·c#
¥-oriented3 小时前
【C#中路径相关的概念】
开发语言·c#
CoderCodingNo3 小时前
【GESP】C++四级考试大纲知识点梳理, (7) 排序算法基本概念
开发语言·c++·排序算法