首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在netty "Reflective setAccessible(true) disabled“的情况下出现spring-web-flux错误

在netty "Reflective setAccessible(true) disabled“的情况下出现spring-web-flux错误
EN

Stack Overflow用户
提问于 2019-12-19 22:33:51
回答 1查看 4K关注 0票数 4

我有一个类似上面的junit测试,但是当我启动测试时,我得到这个错误(JDK 13.0.1):

代码语言:javascript
运行
复制
java.lang.UnsupportedOperationException: Reflective setAccessible(true) disabled
java.lang.IllegalAccessException: class io.netty.util.internal.PlatformDependent0$6 cannot access class jdk.internal.misc.Unsafe (in module java.base) because module java.base does not export jdk.internal.misc to unnamed module @4a94ee4

我的工具是Intellij CE Edition 2019.3.1。这是我的class和pom文件:

代码语言:javascript
运行
复制
    import org.junit.jupiter.api.Assertions;
    import org.junit.jupiter.api.Test;
    import org.springframework.web.reactive.function.client.WebClient;
    import reactor.core.publisher.Flux;

    class WebClientStockClientIntegrationTest {

        private static final String SYMBOL = "EUR";
        private WebClient webClient = WebClient.builder().build();

        @Test
        void shouldRetrieveStockPricesFromStockService() {
            WebClientStockClient webClientStockClient = new WebClientStockClient(webClient);
            Flux<StockPrice> prices = webClientStockClient.pricesFor(SYMBOL);
            Assertions.assertNotNull(prices);
            Assertions.assertTrue(prices.take(5).count().block() > 0);
        }
}

我的pom带有spring-boot和依赖项:

代码语言:javascript
运行
复制
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.2.RELEASE</version>
        ..

    <properties>
        <java.version>11</java.version>
    </properties>
EN

回答 1

Stack Overflow用户

发布于 2019-12-19 22:56:56

我解决了:我补充道:

代码语言:javascript
运行
复制
--add-opens java.base/jdk.internal.misc=ALL-UNNAMED -Dio.netty.tryReflectionSetAccessible=true

添加到我的测试配置

票数 8
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59411821

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档