问题
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