【发布时间】:2021-01-12 07:00:06
【问题描述】:
我很难理解这些错误的含义,更不用说开始解决它们了。我正在尝试将 java 平台模块(使用 jdk 14)与一个简单的“基于 gradle 的多模块”项目(使用 jdk 8 一切正常)一起使用。该项目使用 spring-boot 和 spring-data-jdbc。其实我的核心依赖是
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-freemarker'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.projectlombok:lombok'
当我将 module-info.java 添加到每个项目源根目录时,我的 IDE (intellJ) 非常友好地提示我要导出/需要哪些模块,并且在我开始编译之前一切看起来都很好。
我在此处包含一个 git repo 链接,指向作为此问题主题的项目 - https://github.com/m41na/todo-modules-demo
如果您遇到了这些(或类似)问题,您能否说明一下您是如何解决这些问题的?
error: the unnamed module reads package org.springframework.data.jdbc.core.convert from both spring.data.jdbc and spring.data.relational
error: module spring.context reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.boot.starter.data.jdbc reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.boot.starter.jdbc reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.data.jdbc reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.boot.starter reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.jdbc reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.tx reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.boot.autoconfigure reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.boot reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.aop reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.expression reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
the unnamed module reads package org.springframework.data.jdbc.core.convert from both spring.data.jdbc and spring.data.relational
error: module spring.core reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.boot.starter.logging reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module logback.classic reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module org.apache.logging.slf4j reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
module spring.context reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module jul.to.slf4j reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module org.slf4j reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
module spring.boot.starter.data.jdbc reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module java.annotation reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
module spring.boot.starter.jdbc reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module org.yaml.snakeyaml reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.jcl reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
module spring.data.jdbc reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module logback.core reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.beans reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
module spring.boot.starter reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.data.relational reads package org.springframework.data.jdbc.core.convert from both spring.data.jdbc and spring.data.relational
module spring.jdbc reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.data.commons reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
module spring.tx reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
【问题讨论】:
-
我对您的情况一无所知,但是您显示的错误表明您的类路径中有两个 jar 正在贡献具有相同名称的包,因此系统(可能是 ClassLoader ) 不知道该使用哪一个。
spring.data.relational和spring.data.jdbc是以某种方式与这些 jar 相关联的名称。我会寻找这些名称在您的设置中出现的位置,并且可能会尝试消除其中一个。我不知道在 Gradle 中排除包的具体细节......我使用 Maven。 -
„...如果您遇到这些(或类似)问题...“ – @StephenMaina – 我最近解决了 (1)、(2) 和 ( 3) 与 com.lingocoder.mrjar plugin。将MRE 发送到 git hub,我可以帮助您应用该插件来修复您的 MRE。 TIA。
-
我看到 lingocoder 有一个很大的红色免责声明 '由于 Gradle 5.6.1 中的重大更改,确认当前版本的 mrJar 仅适用于 Gradle 版本 5.0.0 到 5.5。 1'。这在我的情况下不起作用,因为我使用的是 gradle 6.5
-
为了完整起见,我添加了一个演示项目的链接,这是这个问题的主题 - github.com/m41na/todo-modules-demo
-
„......一个很大的免责声明......“ - @StephenMaina - 这只是一个旧文档。自编写以来,mrJar v0.0.16 已通过Gradle 5.6.2, 6.0.x, 6.1.x and 6.6.1 成功测试。查看项目4、5 和others。
标签: java spring spring-data java-platform-module-system spring-data-jdbc