java - Java 9 模块如何解决与传递依赖相关的问题?

标签 java java-9 java-module transitive-dependency

我读到,java 9 模块有助于解决由于传递依赖而拉取同一依赖项的多个版本时出现的问题。我不明白为什么。如果您带多个模块,您也会遇到同样的问题。我的意思是,如果其中一个模块引入了一个 hamcrest 版本,而其他模块引入了其他测试工具,则引入了版本 2、3、4 或其他版本的 mockito 或 junit。这些模块如何帮助解决这个问题?

最佳答案

When searching a module path for a module of a particular name, the module system takes the first definition of a module of that name. Version strings, if present, are ignored; if an element of a module path contains definitions of multiple modules with the same name then resolution fails and the compiler, linker, or virtual machine will report an error and exit. It is the responsibility of build tools and container applications to configure module paths so as to avoid version conflicts; it is not a goal of the module system to address the version-selection problem.

http://openjdk.java.net/jeps/261

简而言之,您可以将模块命名为将特定于版本的字符串作为其名称的一部分,但大致就是这样。

关于java - Java 9 模块如何解决与传递依赖相关的问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51604705/

相关文章:

java - 是否建议为程序中的每个类编写一个测试用例?

java - 我登录时解析对象没有此 key 的数据

reactive-programming - 从 react 流 SubmissionPublisher 接收项目

java - 如何按字典顺序对二维数组进行排序?

java - 无法使用 JNA : com. sun.jna.Library 不可访问

java - 让 Eclipse 与 JPMS 和 Maven 良好配合

java - 我的模块化库的用户有什么方法可以访问尚未导出的类?

java - 在 Java 中使用扭曲的子类化构建器模式

java - (高中Java作业帮助)英文字母转摩尔斯电码的困惑

java - 从 java 9 中的模块类调用非模块类