Modules A and B export package some.package to module C in Java 9

旧时模样 提交于 2019-12-22 05:29:15

问题


I have three modules module-a, module-b and module-c. When I run my application I get the following:

Error occurred during initialization of boot layer java.lang.module.ResolutionException: Modules module-a and module-b export package some.package to module module-c

What does it mean, taking into consideration that module-c doesn't import some.package and how to fix it?


回答1:


Looks like you've created a split package, meaning two modules (module-a and module-b in your case) contain the same package (some.package). The module system does not allow that. If you place both modules on the module path, you will get this error regardless of whether the package is exported or whether a third module depends on the other two.

The fix is, not to create modules that share the same package. This is not only a technical solution, it also improves the design by making sure each module has a specific and unique API.



来源:https://stackoverflow.com/questions/46277188/modules-a-and-b-export-package-some-package-to-module-c-in-java-9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!