开发者

How to link two or more projects in Eclipse?

开发者 https://www.devze.com 2023-04-09 06:20 出处:网络
I am trying to develop my application in different Eclipse Java projects where each will contain a certain feature. Then I want to combine them in one complete Java project.

I am trying to develop my application in different Eclipse Java projects where each will contain a certain feature. Then I want to combine them in one complete Java project.

However, I have a problem when linking the sources.

The sub-projects can correctly refer to parent-project classes but some of the source files that are accessed by the parent projects cannot be identified in the sub-projects.

I have a workspace/ParentProject/src/main/resources/file, where in the ParentProject I am accessing with "src\main\resources\" from within Java.

However, at runtime the ChildProject throws an exception that they cannot access the file : 'file:/E:/Eclipse%20workspace/ChildProject/src/main/resources/file'

So, when using a method of the ParentProject from the ChildProject, the classpath is somewhat transfered to the ChildProject. My question is how to resolve this.

I hope I made it clear what the problem is and will be really appreciative for any help.

Regar开发者_高级运维ds,

Petar

Btw: It is explained there How to link project in eclipse but I still have the error, that the child project cannot access resources accessed by the parent project.


Although I am not entirely sure what you need to do, it sounds to me that you are trying to create circular dependencies, which is an anti-pattern. You want to avoid creating dependencies where project a depends on project b, but project b also depends on project a. If you provide more details on your use case and what you are trying to create I will be happy to provide some guidance as to how you could structure your dependencies.

Hope this helps.


Right click the Parent project and click properties. Then click Java Build Path on the left hand side. Next click the projects tab. Make sure the Child project is selected as a required project, if it is not Add the Child project.

You should also do this for the Parent Project.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号