了解 JPMS 模块的错误 [英] Understanding errors with JPMS modules

查看:39
本文介绍了了解 JPMS 模块的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难理解这些错误的含义,更不用说开始解决它们了.我正在尝试使用带有简单的基于 gradle 的多模块"的 java 平台模块(使用 jdk 14).项目(使用 jdk 8 一切正常).该项目使用 spring-boot 和 spring-data-jdbc.其实我的核心依赖是

实现'org.springframework.boot:spring-boot-starter-data-jdbc'实现 'org.springframework.boot:spring-boot-starter-freemarker'实现 'org.springframework.boot:spring-boot-starter-web'实施 'org.projectlombok:lombok'

当我将 module-info.java 添加到每个项目源根目录时,我的 IDE (intellJ) 非常友好地向我提示要导出/需要哪些模块,并且在我尝试编译之前一切看起来都很好.

我在此处包含指向该问题主题的项目的 git repo 链接 - https://github.com/m41na/todo-modules-demo

如果您遇到这些(或类似)问题,能否请您说明一下您是如何解决这些问题的?

error: the unnamed module 从 spring.data.jdbc 和 spring.data.relational 读取包 org.springframework.data.jdbc.core.convert错误:模块 spring.context 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert错误:模块 spring.boot.starter.data.jdbc 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert错误:模块 spring.boot.starter.jdbc 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert错误:模块 spring.data.jdbc 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert错误:模块 spring.boot.starter 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert错误:模块 spring.jdbc 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert错误:模块 spring.tx 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert错误:模块 spring.boot.autoconfigure 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert错误:模块 spring.boot 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert错误:模块 spring.aop 从​​ spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert错误:模块 spring.expression 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert未命名模块从 spring.data.jdbc 和 spring.data.relational 读取包 org.springframework.data.jdbc.core.convert错误:模块 spring.core 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert错误:模块 spring.boot.starter.logging 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert错误:模块 logback.classic 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert错误:模块 org.apache.logging.slf4j 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert模块 spring.context 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert错误:模块 jul.to.slf4j 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert错误:模块 org.slf4j 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert模块 spring.boot.starter.data.jdbc 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert错误:模块 java.annotation 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert模块 spring.boot.starter.jdbc 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert错误:模块 org.yaml.snakeyaml 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert错误:模块 spring.jcl 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert模块 spring.data.jdbc 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert错误:模块 logback.core 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert错误:模块 spring.beans 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert模块 spring.boot.starter 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert错误:模块 spring.data.relational 从 spring.data.jdbc 和 spring.data.relational 读取包 org.springframework.data.jdbc.core.convert模块 spring.jdbc 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert错误:模块 spring.data.commons 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert模块 spring.tx 从 spring.data.relational 和 spring.data.jdbc 读取包 org.springframework.data.jdbc.core.convert

解决方案

TL;DR — 我已经解决了你的 拆分包 错误在你的这个克隆中项目使用mrJar Gradle 插件1.


冗长的答案

<块引用>

……我很难理解这些错误的含义……

欢迎来到 拆分包...

<块引用><块引用>

...拆分包"是一个古老的 Java 术语,其中两个具有相同名称的包存在于不同的库/应用程序中.由于配置可靠,Java 9 不允许在不同模块中拆分包……

这句话来自 这个博客.

<块引用>

...如果您遇到这些(或类似)问题...

作为 其他几个堆栈溢出问题 证明,对于任何将项目构建为 JPMS 模块的人来说,拆分包是不可避免的.

<块引用>

……您能否解释一下您是如何解决这些问题的?……

回顾TL;DR,我已经通过应用我建议的插件解决了您项目的拆分包问题.下载并构建演示以检查结果.

正如我在该演示的文档中提到的,Java 14+ 支持将在接下来的一两天内添加到该插件中.尽快,我将更新演示并编辑此答案.但我认为与其等到那时,您(和其他感兴趣的潜伏者)可以今天从 0.0.16 版的 JDK 13 支持中受益.

我最近提出的另一个解决方案是 Mark Reinhold 建议的实现 „连接类路径方法.数字 23 我在评论中提到的就是采用这种方法.但我个人更喜欢插件方法.这更容易,也更省力.






1 我很清楚mrJar 插件正在升级,支持 JDK14+.v0.0.17 的发布预计将在接下来的 1-2 天内公布.

I am having a rough time deciphering what these errors mean, let alone even begin to resolve them. I am trying to use java platform modules (using jdk 14) with a simple "gradle-based, multi-module" project (everything works perfectly fine with jdk 8). The project makes use of spring-boot and spring-data-jdbc. Actually my core dependencies are

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'

While I was adding module-info.java to each project source root, my IDE (intellJ) was very kind to give me hints of what modules to export/require, and all looked good until I tred to compile.

I am including a git repo link here to the project that's th topic of this question - https://github.com/m41na/todo-modules-demo

If you have come across these (or similar) issues, could you please shed some light on how you were able to resolve them?

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

解决方案

TL;DR — I've solved your split packages errors in this clone of your project using the mrJar Gradle plugin1.


The long-winded answer

…I am having a rough time deciphering what these errors mean…"

Welcome to the world of split packages

…'Split packages' is an old Java term where two packages having the same name exist in different libraries/applications. Java 9 does not allow split packages in different modules for the reason of the reliable configuration…"

That quote's from this blog.

…If you have come across these (or similar) issues…"

As several other Stack Overflow questions attest, split packages are an inevitability for anybody structuring their projects as JPMS modules.

…could you please shed some light on how you were able to resolve them?…"

Referring back to the TL;DR, I've resolved your project's split packages issue by applying the plugin I proposed. Download and build the demo to examine the results.

As I mention in that demo's documentation, Java 14+ support will be added to that plugin within the next day or two. As soon as it is, I will update the demo and edit this answer. But I figured rather than wait until then, you (and other interested lurkers) could benefit today from version 0.0.16's JDK 13 support.

Another solution I recently proposed is an implementation of Mark Reinhold's suggested „Bridges to the class path" approach. Numbers 2 and 3 that I mentioned in the comments take that approach. But personally I prefer the plugin approach. It's a lot easier and is way less effort.






1 I have it on good authority that the mrJar plugin is in the process of being upgraded with JDK14+ support. Release of v0.0.17 is expected to be announced within the next 1-2 days.

这篇关于了解 JPMS 模块的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆