如何在Eclipse中添加插件依赖

4

我想知道为什么以及如何在Eclipse中为任何项目添加插件依赖。


我建议您使用Apache Maven作为工具,它将负责处理依赖关系。 - ant
3个回答

7

1
如何解决添加到依赖项的插件问题
我需要知道要添加哪个依赖项(到Eclipse插件),以及如何添加它。我在Java代码中遇到了以下错误:
The type org.eclipse.jface.text.source.Annotation cannot be resolved. It is indirectly referenced from required .class files

在Java的“package”语句中:
The hierarchy of the type JavaDecodePlugin is inconsistent

为了找到提供Annotation类的插件,我搜索了Eclipse代码安装在我的(Windows)机器上的“plugins”目录,寻找对该类的引用:
C:\app\androidDev\eclipse\plugins>grep -r org.eclipse.jface.text.source.Annotation *
Binary file org.eclipse.jface.text_3.8.2.v20121126-164145.jar matches
Binary file org.eclipse.text_3.5.200.v20120523-1310.jar matches

这个类被两个插件/ JAR文件引用。我在这些文件中搜索了需要的类。第一个插件/ JAR文件中没有包含它,而第二个包含了。

C:\app\androidDev\eclipse\plugins>jar -tf org.eclipse.jface.text_3.8.2.v20121126-164145.jar |grep Annotations
org/eclipse/jface/text/link/LinkedPositionAnnotations.class
org/eclipse/jface/text/source/projection/ProjectionSupport$ProjectionAnnotationsPainter.class

C:\app\androidDev\eclipse\plugins>jar -tf org.eclipse.text_3.5.200.v20120523-1310.jar |grep Annotations
org/eclipse/jface/text/source/Annotation.class
org/eclipse/jface/text/source/AnnotationMap.class
org/eclipse/jface/text/source/AnnotationModel$1.class
org/eclipse/jface/text/source/AnnotationModel$2.class
org/eclipse/jface/text/source/AnnotationModel$AnnotationsInterator.class
org/eclipse/jface/text/source/AnnotationModel$InternalModelListener.class
org/eclipse/jface/text/source/AnnotationModel$MetaIterator.class
org/eclipse/jface/text/source/AnnotationModel$RegionIterator.class
org/eclipse/jface/text/source/AnnotationModel.class
org/eclipse/jface/text/source/AnnotationModelEvent.class

所以我现在知道需要哪个插件了。就像Plug-in Dependencies中所示(如上面的答案所示),您需要进入“包资源管理器”,展开“META-INF”,打开“MANIFEST.MF”,打开“依赖项”选项卡,然后在“必需插件”部分的“添加”按钮上点击,在“选择插件”文本区域中键入插件名称的一部分,让它找到插件的全名(也许选择所需的插件),然后单击“确定”。

(此答案有点像记录过程,以便如果我忘记了自己做了什么,我和您都会知道)


1
点击项目,选择属性,进入Java Build Path..添加JAR文件或添加外部JAR文件应该可以解决您的问题。

在同一工作区中依赖其他项目怎么样?似乎它们不起作用。 - smiron

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接