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>
相关推荐
巴拉巴拉~~1 分钟前
KMP 算法通用步进器组件:KmpStepperWidget 横向 / 纵向 + 匹配进度 + 全样式自定义
java·服务器·开发语言
weixin_307779132 分钟前
赋能插件,驱动图表:Jenkins ECharts API插件详解
运维·开发语言·自动化·jenkins·echarts
贺今宵3 分钟前
使用idea启动一个springboot项目
java·ide·intellij-idea
IMPYLH4 分钟前
Lua 的 Math(数学) 模块
开发语言·笔记·lua
伍一5114 分钟前
芋道框架下的进销存升级(三):Yudao-ERP2异步导出/导入Excel的设计与实现
java·excel·异步导出excel
kaikaile199514 分钟前
雷达仿真中时域与频域脉冲压缩的对比 MATLAB实现
开发语言·matlab
胡闹5414 分钟前
【EasyExcel】字段赋值错乱问题
java·开发语言
断剑zou天涯14 分钟前
【算法笔记】AC自动机
java·笔记·算法
张工摆Bug15 分钟前
《别再写满屏的if-else了!Spring Boot + 策略模式实战优化》
java
独自归家的兔16 分钟前
基于GUI-PLUS 搭配 Java Robot 实现智能桌面操控
java·开发语言·人工智能