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>
相关推荐
014-code6 小时前
订单超时取消与库存回滚的完整实现(延迟任务 + 状态机)
java·开发语言
lly2024066 小时前
组合模式(Composite Pattern)
开发语言
游乐码6 小时前
c#泛型约束
开发语言·c#
Dontla6 小时前
go语言Windows安装教程(安装go安装Golang安装)(GOPATH、Go Modules)
开发语言·windows·golang
chushiyunen6 小时前
python rest请求、requests
开发语言·python
铁东博客7 小时前
Go实现周易大衍筮法三变取爻
开发语言·后端·golang
baidu_huihui7 小时前
在 CentOS 9 上安装 pip(Python 的包管理工具)
开发语言·python·pip
南 阳7 小时前
Python从入门到精通day63
开发语言·python
lbb 小魔仙7 小时前
Python_RAG知识库问答系统实战指南
开发语言·python
java1234_小锋7 小时前
Java高频面试题:Springboot的自动配置原理?
java·spring boot·面试