Java 如何在 IntelliJ Idea 中添加项目以构建路径

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34832059/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 16:01:37  来源:igfitidea点击:

How to add a project to build path in IntelliJ Idea

javaandroideclipseintellij-idea

提问by arabian_albert

I've recently converted over to IntelliJ Idea 13, previously in eclipse I was able to add a project to another project's build path. I'm not able to accomplish this in IntelliJ.

我最近转换到 IntelliJ Idea 13,之前在 eclipse 中我能够将一个项目添加到另一个项目的构建路径。我无法在 IntelliJ 中完成此操作。

How can I add project1 to project2's build path so that I can use it as a dependency. I don't want to make that project a JAR because I'm still developing it.

如何将 project1 添加到 project2 的构建路径,以便我可以将其用作依赖项。我不想让那个项目成为 JAR,因为我还在开发它。

Following this similar previous question: Intellij - Add project dependency like in Eclipse

按照这个类似的上一个问题: Intellij - Add project dependency like in Eclipse

I was not able to successfully achieve my goal.

我没能成功实现我的目标。

In File > Project Structure > Modules

在文件 > 项目结构 > 模块中

I see the project I'd like to add to my build path (DataProvider) but it's highlighted red, and the bottom warning text states "Invalid item 'DataProvider' in dependencies list'

我看到了我想添加到我的构建路径 (DataProvider) 中的项目,但它以红色突出显示,底部警告文本指出“依赖项列表中的项目‘DataProvider’无效”

enter image description here

在此处输入图片说明

Any help or assistance would be much appreciated.

任何帮助或协助将不胜感激。

Edit:

编辑:

Solution(Thanks @leeor)

解决方案(感谢@leeor)

Import project as a module

将项目作为模块导入

File > Import Module > (Select Project to be imported)

文件 > 导入模块 > (选择要导入的项目)

This will add that project to the project view pane on the left side of the screen.

这会将该项目添加到屏幕左侧的项目视图窗格中。

Then go to your current project

然后转到您当前的项目

File > Project Structure > Module > (Select your current project)

文件 > 项目结构 > 模块 >(选择您当前的项目)

Under Dependencies

在依赖项下

Check mark your project (now a module) you want to import and then click apply and then OK.

选中要导入的项目(现在是模块),然后单击应用,然后单击确定。

Done!

完毕!

Using IntelliJ Idea 13.1.6 on Mac

在 Mac 上使用 IntelliJ Idea 13.1.6

采纳答案by leeor

If you want to depend on another module without it being jar, you need to import that as a module into the same project. It doesn't look like DataProvideris imported since it doesn't appear in the module list.

如果你想依赖另一个模块而不是 jar,你需要将它作为一个模块导入到同一个项目中。它看起来不像DataProvider是导入的,因为它没有出现在模块列表中。