【问题标题】:Java9 module error: Can not determine the module name, the unnamed module reads package and module org.reactivestreams reads package from bothJava9模块错误:无法确定模块名称,未命名模块读取包和模块org.reactivestreams从两者读取包
【发布时间】:2023-03-17 14:54:05
【问题描述】:

我收到 3 个不同的错误。

  1. 无法确定模块名称..
  2. 未命名的模块读取包..
  3. 模块 org.reactivestreams 从两者中读取包..

这些错误到底是什么?

build.gradle

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-webflux'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
     exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
     exclude group: 'org.mockito', module: 'mockito-core'
    }
 
    testImplementation 'io.projectreactor:reactor-test'
    testImplementation 'org.springframework.restdocs:spring-restdocs-webtestclient'
   

    compile("io.github.resilience4j:resilience4j-spring-boot2:1.3.1") {
     exclude group: 'org.mockito', module: 'mockito-core'
     }
   compile("io.github.resilience4j:resilience4j-reactor:1.3.1") {
     exclude group: 'org.mockito', module: 'mockito-core'
   }
   compile('org.springframework.boot:spring-boot-starter-aop')
   compile('org.springframework.boot:spring-boot-starter-actuator')
   compile group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
}

错误信息:

任务:compileJava

错误:无法确定 /Users/srihariprasad/.gradle/caches/modules-2/files-2.1/io.github.resilience4j/resilience4j-framework-common/1.3.1/8c16dda86fad3c9251930cad21ac87aa34cd8035/resilience4j-framework- 的模块名称common-1.3.1.jar

错误:未命名的模块从resilience4j.spring.boot.common 和io.github.resilience4j.springboot2 读取包io.github.resilience4j.timelimiter.autoconfigure

错误:未命名的模块从弹性4j.spring.boot.common 和io.github.resilience4j.springboot2 读取包io.github.resilience4j.retry.autoconfigure

错误:未命名的模块从弹性4j.spring.boot.common 和io.github.resilience4j.springboot2 读取包io.github.resilience4j.ratelimiter.autoconfigure 错误:未命名的模块从resilience4j.spring.boot.common 和io.github.resilience4j.springboot2 读取包io.github.resilience4j.circuitbreaker.autoconfigure 错误:未命名的模块从弹性4j.spring.boot.common和io.github.resilience4j.springboot2读取包io.github.resilience4j.bulkhead.autoconfigure

错误:模块 org.reactivestreams 从弹性4j.spring.boot.common 和 io.github.resilience4j.springboot2 读取包 io.github.resilience4j.timelimiter.autoconfigure

我们怎样才能从哪个jar中找到这两个模块,排除那些。 1.resilience4j.spring.boot.common,2.io.github.resilience4j.springboot2。根据我的理解,我需要从弹性4j-spring-boot2:1.3.1 中排除罐子。但是我不明白怎么做?

【问题讨论】:

  • 这是否回答了您的问题 - How to resolve module reads package error in java9
  • 如果我从 gradle 中删除这两个依赖项,它的工作正常,但我需要这些 compile("io.github.resilience4j:resilience4j-spring-boot2:1.3.1") { exclude group: 'org .mockito',模块:'mockito-core'} compile("io.github.resilience4j:resilience4j-reactor:1.3.1") {排除组:'org.mockito',模块:'mockito-core'}跨度>

标签: java spring-boot java-9 java-11 resilience4j


【解决方案1】:

未命名模块导出的包只能被另一个未命名模块读取。命名模块不可能读取(需要)未命名模块。 http://tutorials.jenkov.com/java/modules.html#unnamed-module

您将 Resilience4j 用作自动模块,但不允许拆分包的规则也适用于自动模块。如果多个 JAR 文件包含(并因此导出)同一个 Java 包,那么这些 JAR 文件中只有一个可以用作自动模块。 我们必须在 Resilience4j 中修复这个拆分包问题。在此之前,您可以在运行应用程序时使用 Java VM 的 -classpath 参数。在类路径中,您可以包含所有较旧的 Java 类,就像您在 Java 9 之前所做的那样。在类路径中找到的所有类都将包含在 Java 所称的未命名模块中。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-11-25
  • 2014-11-09
  • 1970-01-01
  • 2023-03-17
  • 1970-01-01
  • 1970-01-01
  • 2018-09-01
相关资源
最近更新 更多