【问题标题】:spring-web-flux error with netty "Reflective setAccessible(true) disabled"带有netty“反射setAccessible(true)禁用”的spring-web-flux错误
【发布时间】:2020-04-12 04:11:35
【问题描述】:

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

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。 这是我的课程和 pom 文件:

    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 和依赖项:

    <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>

【问题讨论】:

    标签: java spring-boot spring-webflux reactor-netty


    【解决方案1】:

    我解决了: 我补充说:

    --add-opens java.base/jdk.internal.misc=ALL-UNNAMED -Dio.netty.tryReflectionSetAccessible=true
    

    到我的测试配置

    【讨论】:

      猜你喜欢
      • 2020-05-31
      • 2012-05-25
      • 2019-10-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-16
      • 2019-12-16
      • 2016-07-05
      相关资源
      最近更新 更多