简体   繁体   English

如何在 Java Project Intellij 中向其他模块添加模块依赖

[英]How to add module dependency to other module in Java Project Intellij

I havr two modules in this project (JavaRESTfulEngine and Models).我在这个项目中有两个模块(JavaRESTfulEngine 和 Models)。 Java RESTful engine depends on models. Java RESTful 引擎依赖于模型。 在此处输入图片说明

I added the dependency here:我在这里添加了依赖项: 在此处输入图片说明

But in my JavaRESTfulEngine project I still get reference errors.但是在我的 JavaRESTfulEngine 项目中,我仍然收到引用错误。 For example, the Document class is in the Models module, but I cannot find it when trying to import the class in JavaRESTful module:例如,Document 类位于 Models 模块中,但在尝试导入 JavaRESTful 模块中的类时找不到它: 在此处输入图片说明 The goal is that Models is compiled down to a jar and used in the JavaRESTful project during runtime.目标是将模型编译为 jar 并在运行时在 JavaRESTful 项目中使用。 Does anything stand out as wrong in my setup?我的设置中是否有任何问题? EDIT I changed the scope from compile to provided and it still doesnt work.编辑我将范围从编译更改为提供,但它仍然不起作用。

You don't have to change the scope of the jars.您不必更改罐子的范围。 If you want to use the libraries of the Models module in the JavaRESTfulEngine module, you just have to make sure that each jar you want to reuse from Models has the "Export" check box activated and that the reference to the Models folder is inside the JavaRESTfulEngine module (just like I see you have it in the second photo)如果要在JavaRESTfulEngine模块中使用Models模块的库,只需确保要从Models重用的每个 jar 都激活了“导出”复选框,并且对Models文件夹的引用位于JavaRESTfulEngine模块(就像我在第二张照片中看到的那样)

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

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