简体   繁体   English

Eclipse项目参考层次结构

[英]Eclipse Project Reference Hierarchy

I am working on creating pluggable modules in my Product and have thus created multiple Java projects in my eclipse Workspace. 我正在我的产品中创建可插拔模块,因此在Eclipse工作区中创建了多个Java项目。 I wish to maintain a proper hierarchy of project references so suppose the project works something like this: 我希望维护项目引用的适当层次结构,因此假设项目的工作方式如下:

  • Core Project (refers nothing). 核心项目(无所指)。
  • Project 1 (refers Core Project). 项目1(指核心项目)。
  • Project 2 (Refers to Project 1 as well as Core Project). 项目2(指项目1和核心项目)。

Now in the Build path of Project 1 I have added Core Project in the Projects tab. 现在,在项目1的构建路径中,我在“项目”选项卡中添加了核心项目。
Now in the Build path of Project 2 I have added only the reference of Project 1 assuming that since Project 1 refers to Core Project, the references for Core Project will be available in Project 2 as well. 现在,在项目2的构建路径中,我仅添加了项目1的引用,并假设由于项目1引用了核心项目,因此在项目2中也可以使用核心项目的引用。 But unfortunately Core Project is not visible to Project 2. 但是不幸的是核心项目对项目2不可见。
Would love any help I can get in achieving such a hierarchy if it is possible in Eclipse. 如果可以在Eclipse中获得实现这样的层次结构的任何帮助,我们将不胜感激。

You'd better use maven and m2e plugin (eclipse maven integration) 您最好使用Maven和M2e插件(Eclipse Maven集成)

  1. Add core dependency to project 1 将核心依赖项添加到项目1
  2. Add project 1 dependency to project 2 将项目1依赖项添加到项目2

Let maven and eclipse do their job, everything will work like a charm.. 让Maven和Eclipse做好自己的工作,一切都会像魅力一样运作。

由于似乎您要从项目2访问“核心”类,因此将核心作为项目2的依赖关系引用并不是错误的

Well, I posted the query to bug.eclipse.org and finally got the answer to it. 好吧,我将查询发布到bug.eclipse.org,最后得到了答案。 Here is the link to the solution - https://bugs.eclipse.org/bugs/show_bug.cgi?id=472030 这是解决方案的链接-https: //bugs.eclipse.org/bugs/show_bug.cgi?id=472030

Goto the Order and Export tab of Project 1 in Configure Build path menu and check the checkbox beside Core Project. 转到“配置构建路径”菜单中项目1的“订购和导出”选项卡,然后选中“核心项目”旁边的复选框。 And then it is visible to the Project 2. 然后对项目2可见。
This is so because Eclipse does not export its dependencies by default. 之所以这样,是因为Eclipse在默认情况下不会导出其依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM