Eclipse Java编辑器突出显示该错误,但代码可以编译 [英] Eclipse Java Editor highlights the error but code compiles
问题描述
在使用JDK 11,Eclipse 2019-03和jaxb-api(版本2.4,最新版本可在maven存储库中使用)时,Eclipse中的Java编辑器突出显示以下一行:
When using JDK 11, Eclipse 2019-03 and jaxb-api (version 2.4, latest available in maven repository), Java Editor in Eclipse highlights the line:
import javax.xml.XMLConstants;
作为错误:
可以从多个模块访问包javax.xml:未命名的java.xml
The package javax.xml is accessible from more than one module: unnamed, java.xml
但是代码可以编译在问题选项卡中不会显示任何错误。删除jaxb-api依赖关系会使错误消失。此项目中的jaxb-api位于类路径上,并包含以下软件包:
But the code compiles and no errors are displayed in Problems tab. Removing jaxb-api dependency makes the error go away. jaxb-api in this project is on the classpath and contains the following packages:
javax.xml.bind;
javax.xml.bind.annotation;
javax.xml.bind.annotation.adapters;
javax.xml.bind.attachment;
javax.xml.bind.helpers;
javax.xml.bind.util;
是Eclipse中的错误还是依赖项/项目中的问题?
Is it a bug in Eclipse or a problem in the dependency/project?
推荐答案
是的,这是Eclipse 2019-03 Java IDE的错误(在 jaxb-api
javax.xml
是允许的子包,但不是允许的子包):
Yes, this is a bug of the Eclipse 2019-03 Java IDE (in jaxb-api
javax.xml
is a subpackage, which is allowed, but not a real package, which would not be allowed):
Eclipse Bug 546315 -[11]包[…]可以通过多个模块访问:,[…]错误在Java编辑器中错误显示
Eclipse Bug 546315 - [11] "The package […] is accessible from more than one module: , […]" error shown in Java editor by mistake
该错误已得到修复。因此,要么忽略它(因为代码已编译),要么使用像Eclipse 2019-06(4.12)这样的较新版本。
The bug has already been fixed. So either ignore it (since the code is compiled) or use a newer version like Eclipse 2019-06 (4.12).
这篇关于Eclipse Java编辑器突出显示该错误,但代码可以编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!