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

How Java 9 modules solve problems associated with transitive dependencies?

我读到 java9 个模块有助于解决由于传递依赖而拉取同一依赖的多个版本时出现的问题。我不明白为什么。如果你带了几个模块,你也会遇到同样的问题。我的意思是,如果其中一个模块引入了一个 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

简而言之,您可以命名您的模块,将特定于版本的字符串作为其名称的一部分,但仅此而已。