Java 9:在 Eclipse 中无法访问模块 java.xml.bind
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46852065/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java 9: Module java.xml.bind is not accessible in Eclipse
提问by user3133542
I migrating a maven project in Java 8to a Java 9project without any build tool in Eclipse OxyGen 1a
.
我将Java 8 中的 Maven 项目迁移到Java 9项目,而Eclipse OxyGen 1a
.
So my module-info.javalooks like this:
所以我的module-info.java看起来像这样:
But java.xml.bind is not accessible, although its in my module path:
但是 java.xml.bind 不可访问,尽管它在我的模块路径中:
So what is wrong here?
那么这里有什么问题呢?
采纳答案by Stephan Herrmann
When compiling an unnamed module, java.xml.bind
is not accessible by default, but in a modular project (as in this question) failing to resolve reference to module java.xml.bind
was a bug(see edit below).
编译未命名模块时,java.xml.bind
默认情况下不可访问,但在模块化项目中(如本问题),未能解析对模块的引用java.xml.bind
是一个错误(请参阅下面的编辑)。
To work around this until the bug is fixed, you can explicitly includemodule java.xml.bind
by double click on Is modular
(see screenshot in the question), and in the dialog that shows, move the desired module from Available modules
to Explicitly included modules
:
要解决此问题,直到修复错误,您可以通过双击明确包含模块(请参阅问题中的屏幕截图),并在显示的对话框中,将所需模块从 移动到:java.xml.bind
Is modular
Available modules
Explicitly included modules
Edit: Bug 526054has been resolved in Eclipse Oxygen.2, and thus a modular project should no longer need the steps above (which are still relevant for code in an unnamed module, though).
编辑:错误 526054已在 Eclipse Oxygen.2 中解决,因此模块化项目不再需要上述步骤(尽管这些步骤仍然与未命名模块中的代码相关)。
Edit 2: In Eclipse 2019-06 the UI for tasks like above has been revamped. Up-to-date documentation can be found in the online help.