Eclipse 错误:从所需的 .class 文件间接引用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5547162/
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
Eclipse error: indirectly referenced from required .class files?
提问by karikari
I got an error in Eclipse. What does this error message means:
我在 Eclipse 中遇到错误。此错误消息是什么意思:
The type iglu.ir.TermVector cannot be resolved. It is indirectly referenced from required .class files
无法解析 iglu.ir.TermVector 类型。它是从所需的 .class 文件间接引用的
回答by Arne Deutsch
It means: "A class that you use needs another class that is not on the classpath." You should make sure (as Harry Joy suggests) to add the required jar to the classpath.
这意味着:“您使用的类需要另一个不在类路径上的类。” 您应该确保(如 Harry Joy 所建议的)将所需的 jar 添加到类路径中。
回答by Jerry Miller
This is as likely a matter of Eclipse's getting confused as it is an actual error. I ignored the error and ran the web service whose endpointInterface it complained about, and it ran fine, except for having to deal with the dialog every time I wanted to run it. Just another opaque error that tells me nothing.
这很可能是 Eclipse 变得困惑的问题,因为它是一个实际错误。我忽略了错误并运行了它抱怨的端点接口的 Web 服务,它运行良好,除了每次我想运行它时都必须处理对话框。只是另一个不透明的错误,它什么也没告诉我。
回答by Mário Kapusta
It happens to me sometimes, I always fixed that with "mvn eclipse:clean" command to clean old properties and then run mvn eclipse:eclipse -Dwtpversion=2.0 (for web project of course). There are some old properties saved so eclipse is confused sometimes.
有时会发生在我身上,我总是使用“mvn eclipse:clean”命令来清理旧属性,然后运行 mvn eclipse:eclipse -Dwtpversion=2.0 (当然是针对 Web 项目)。保存了一些旧属性,因此 eclipse 有时会感到困惑。
回答by Xavier Portebois
I had this error because of a corrupted local maven repository.
由于本地 maven 存储库损坏,我遇到了此错误。
So, in order to fix the problem, all I had to do was going in my repository and delete the folder where the concerned .jar was, then force an update maven
in Eclipse.
所以,为了解决这个问题,我所要做的就是进入我的存储库并删除相关 .jar 所在的文件夹,然后update maven
在 Eclipse 中强制执行。
回答by NPKR
It sounds like this has been a known issue (Bug 67414)that was resolved in 3.0 ... someone has commented that it's occurring for them in 3.4 as well.
听起来这是一个已知问题(错误 67414),已在 3.0 中解决……有人评论说,在 3.4 中也发生了这种情况。
In the mean time, the work around is to remove the JRE System Library from the project and then add it back again.
同时,解决方法是从项目中删除 JRE 系统库,然后重新添加它。
Here are the steps:
Go to properties of project with the build error (right click > Properties)
转到带有构建错误的项目属性(右键单击 > 属性)
View the "Libraries" tab in the "Build Path" section
查看“构建路径”部分中的“库”选项卡
Find the "JRE System Library" in the list (if this is missing then this error message is not an eclipse bug but a mis-configured project)
在列表中找到“JRE 系统库”(如果没有,则此错误消息不是 Eclipse 错误而是配置错误的项目)
Remove the "JRE System Library"
删除“JRE 系统库”
Hit "Add Library ...", Select "JRE System Library" and add the appropriate JRE for the project (eg. 'Workspace default JRE')
点击“添加库...”,选择“JRE 系统库”并为项目添加适当的 JRE(例如“工作区默认 JRE”)
Hit "Finish" in the library selection and "OK" in the project properties and then wait for the re-build of the project
在库选择中点击“完成”,在项目属性中点击“确定”,然后等待项目的重新构建
Hopefully the error will be resolved ...
希望错误能得到解决......
回答by Mayur
This error occurs when the classes in the jar file does not follow the same structure as of the folder structure of the jar..
当 jar 文件中的类不遵循与 jar 文件夹结构相同的结构时,会发生此错误。
e.g. if you class file has package com.test.exam and the classes.jar created out of this class file has structure test.exam... error will be thrown. You need to correct the package structure of your classes.jar and then include it in ecplipse build path...
例如,如果您的类文件包含 com.test.exam 包,并且由此类文件创建的 classes.jar 具有结构 test.exam... 将抛出错误。您需要更正 classes.jar 的包结构,然后将其包含在 eclipse 构建路径中...
回答by Orlando Valencia
I got this exception because eclipse was working in a different version of jdk, just changed to the correct, clean and build and worked!
我得到这个异常是因为 eclipse 在不同版本的 jdk 中工作,只是更改为正确的、干净的、构建和工作的!
回答by Renardo
I had an interesting case of this problem with Eclipse 4.4.2. My project (P1) referenced an external class (project P2) with two methods with the same name but different argument types:
我有一个关于 Eclipse 4.4.2 的有趣案例。我的项目 (P1) 引用了一个外部类 (项目 P2),其中包含两个名称相同但参数类型不同的方法:
public static void setItem(Integer id) …
public static void setItem(Item item) …
The type Item
was contained in a third project P3, which I did not want to be visible here. P1 called only the first method:
该类型Item
包含在第三个项目 P3 中,我不想在这里看到它。P1 只调用了第一个方法:
ExternalClass.setItem(Integer.valueOf(12345));
So the second method, which used the Item
class, was not used, and it is true that P3 was not in the compilation classpath – why should it if it is not used.
所以使用Item
类的第二种方法没有使用,而且 P3 确实不在编译类路径中——如果不使用它为什么要使用它。
Still Eclipse told me
Eclipse 仍然告诉我
The type ...Item cannot be resolved.
It is indirectly referenced from required .class files
Compiling from the command line did not produce any such issues. Changing the name of the second method (unused here!) made the problem go away in Eclipse, too.
从命令行编译不会产生任何此类问题。更改第二种方法的名称(此处未使用!)也使 Eclipse 中的问题消失了。
回答by Eduardo Dennis
What fixed it for me was right clicking on project > Maven > Update Project
为我修复的是 right clicking on project > Maven > Update Project
回答by Ming Leung
For me, it happens when I upgrade my jdk to 1.8.0_60 with my old set of jars has been used for long time. If I fall back to jdk1.7.0_25, all these problem are gone. It seems a problem about the compatibility between the JRE and the libraries.
对我来说,当我使用旧的 jar 集将 jdk 升级到 1.8.0_60 时会发生这种情况。如果我回到 jdk1.7.0_25,所有这些问题都没有了。JRE 和库之间的兼容性似乎存在问题。