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>
相关推荐
devmoon3 分钟前
在 Polkadot 上部署独立区块链Paseo 测试网实战部署指南
开发语言·安全·区块链·polkadot·erc-20·测试网·独立链
lili-felicity3 分钟前
CANN流水线并行推理与资源调度优化
开发语言·人工智能
爬山算法4 分钟前
Hibernate(87)如何在安全测试中使用Hibernate?
java·后端·hibernate
沐知全栈开发4 分钟前
CSS3 边框:全面解析与实战技巧
开发语言
island131414 分钟前
CANN GE(图引擎)深度解析:计算图优化管线、内存静态规划与异构 Stream 调度机制
c语言·开发语言·神经网络
云姜.16 分钟前
线程和进程的关系
java·linux·jvm
是码龙不是码农18 分钟前
支付防重复下单|5 种幂等性设计方案(从初级到架构级)
java·架构·幂等性
曹牧18 分钟前
Spring Boot:如何在Java Controller中处理POST请求?
java·开发语言
heartbeat..19 分钟前
JVM 性能调优流程实战:从开发规范到生产应急排查
java·运维·jvm·性能优化·设计规范
浅念-21 分钟前
C++入门(2)
开发语言·c++·经验分享·笔记·学习