Eclipse Java 编辑器突出显示错误但代码编译 [英] Eclipse Java Editor highlights the error but code compiles

查看:55
本文介绍了Eclipse Java 编辑器突出显示错误但代码编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用 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 可以从多个模块访问:unnamed, java.xml

The package javax.xml is accessible from more than one module: unnamed, java.xml

但是代码可以编译并且在问题选项卡中没有显示错误.删除 jaxb-api 依赖会使错误消失.本项目中的jaxb-api在classpath下,包含以下包:

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 的一个 bug(在 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 错误 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆