简体   繁体   English

Junit 5 集成测试在 maven 3.5.2 构建中失败

[英]Junit 5 integration test failed in maven 3.5.2 build

Junit5 integration runs standalone in intellij but fails in maven build with stacktrace as below. Junit5 集成在 intellij 中独立运行,但在使用堆栈跟踪的 maven 构建中失败,如下所示。

Caused by: java.lang.IllegalAccessError: superinterface check failed: class eu.nets.domain.QueuedMessage$HibernateProxy$1spaQq7T (in module eu.nets.queue.domain) cannot access class org.hibernate.proxy.ProxyConfiguration (in unnamed module @0x72a21be8) because module eu.nets.queue.domain does not read unnamed module @0x72a21be8**
    at java.base/java.lang.ClassLoader.defineClass1(Native Method) ~[na:na]
    at java.base/java.lang.System$2.defineClass(System.java:2189) ~[na:na]
    at java.base/java.lang.invoke.MethodHandles$Lookup.defineClass(MethodHandles.java:971) ~[na:na]
    at java.base/jdk.internal.reflect.GeneratedMethodAccessor31.invoke(Unknown Source) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na]
    at net.bytebuddy.dynamic.loading.ClassInjector$UsingLookup$Dispatcher$ForJava9CapableVm.defineClass(ClassInjector.java:1685) ~[byte-buddy-1.9.16.jar:na]
    ... 125 common frames omitted

Please let me know if complete stacktrace is required如果需要完整的堆栈跟踪,请告诉我

  • tried with latest maven-surefire-plugin 3.0.0-M3尝试使用最新的 maven-surefire-plugin 3.0.0-M3
  • ran with jdk11 as release以 jdk11 作为发行版运行

Here is the test:这是测试:

@Test
void fetchMessagesViaAdapter() throws Exception {
    MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders
            .post("/resend")
            .content("[\"queue1\"]")
            .contentType(APPLICATION_JSON_UTF8_VALUE))
                                 .andExpect(status().isOk())
                                 .andReturn();
    String resultDOW = mvcResult.getResponse().getContentAsString();
    assertAll(
            () -> assertNotNull(resultDOW),
            () -> assertEquals("success", resultDOW));
}

module eu.nets.queue.domain does not read unnamed module模块 eu.nets.queue.domain 不读取未命名模块

Based on the error that you get, you can add the following VM option to resolve this -根据您收到的错误,您可以添加以下 VM 选项来解决此问题 -

--add-reads eu.nets.queue.domain=ALL-UNNAMED

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM