简体   繁体   English

使一个项目的罐子可用于另一个从属项目

[英]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中:

  • Class A (extends GenericA) A类(扩展GenericA)

In jar Y: 在罐Y中:

  • Class GenericA 类GenericA
  • Class B B级

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.

相关问题 Intellij:让项目依赖于另一个项目? - Intellij: Making a project dependent on another project? Maven:在项目版本控制中保持依赖的jar - Maven: keeping dependent jars in project version control 如何在另一个项目中包含具有依赖jar的jar文件本身作为依赖关系? - How to include a jar file that has dependent jars with it as a dependency itself in an another project? 使用Maven,我如何构建一个包含我的项目jar和所有依赖jar的distributable? - With Maven, how can I build a distributable that has my project's jar and all of the dependent jars? 在一个项目中使用多个Jars平面项目 - Gradle flat project with multiple Jars in one project Jenkins一个maven项目依赖于另一个正在运行的问题 - Jenkins One maven project dependent on another Running Issue 使图像文件夹在项目中可用 - Making folders of images available in the project Maven可以为项目收集所有依赖JAR以帮助进行应用程序部署吗? - Can Maven collect all the dependent JARs for a project to help with application deployment? 如何包括依赖项目并将jar分为两个jar? - How to include dependent project and splitting jar into two jars? 在Eclipse中,在依赖于maven项目的动态Web项目中,如何从maven项目中拾取jar? - In Eclipse, in a dynamic web project that is dependent on a maven project, how do I pick up jars from the maven project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM