[英]Making one project's jars available to another dependent project
I have two projects X and Y. ProjectX needs jars so I added them to its classpath. 我有两个项目X和Y。ProjectX需要jar,因此我将它们添加到了它的类路径中。 ProjectY needs the classes in ProjectX but also needs the classes in the jars that were added to ProjectX.
ProjectY需要ProjectX中的类,但也需要添加到ProjectX中的jar中的类。 When I add ProjectX to ProjectY's class path, I get an error that Eclipse doesn't find the classes of the jars in its classpath.
当我将ProjectX添加到ProjectY的类路径时,出现一个错误,即Eclipse在其类路径中找不到jar的类。 How to solve this?
如何解决呢? I mean is the only choice is to also add the jars to ProjectY's class path?
我的意思是唯一的选择是也将罐子添加到ProjectY的类路径中吗?
It seems you have cross references. 看来您有交叉引用。
Class A in jar X needs class B in jar Y. But class B also need class A... X罐中的A类需要Y罐中的B类。但是B类也需要A类...
Solution: Create a superclass for A in jar Y. 解决方案:在罐Y中为A创建一个超类。
In jar X: 在罐X中:
In jar Y: 在罐Y中:
Another solutionis to define an interface in jar Y that class A could implement in jar X. 另一种解决方案是在jar Y中定义一个类A可以在jar X中实现的接口。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.