简体   繁体   English

如何将 Intellij 14 中的模块添加到现有项目

[英]How to add module in Intellij 14 to existing project

Recently moved to Intellij from eclipse it seems to be tough to have this setup in intellij 14.最近从 Eclipse 转移到 Intellij 似乎很难在 Intellij 14 中进行此设置。 在此处输入图片说明

Note: I cannot use maven注意:我不能使用 maven

Steps I have followed created a "test project" and "test project 2"我遵循的步骤创建了一个“测试项目”和“测试项目 2”
-> opened test project project structure in cmd+; -> 在 cmd+ 中打开测试项目项目结构; (shortcut in mac) (mac中的快捷方式)
-> in project settings modules clicked on "+" and selected "import module" option -> 在项目设置模块中单击“+”并选择“导入模块”选项
-> selected project 2 -> 选定的项目 2

-> I got this error message stating that -> 我收到此错误消息,指出

cannot save settings, must not contain source root /test/src.无法保存设置,不得包含源根目录 /test/src。 The root belongs to module test`根属于模块 test`

This link is more confusing , could not understand much https://www.jetbrains.com/idea/help/configuring-content-roots.html这个链接比较混乱,看不懂https://www.jetbrains.com/idea/help/configuring-content-roots.html

Can any one explain how to solve this?任何人都可以解释如何解决这个问题吗?

Eclipse's concepts of "workspace" and "project" are matched by IntelliJ IDEA's "project" and "module" respectively. Eclipse 的“工作区”和“项目”概念分别与 IntelliJ IDEA 的“项目”和“模块”相匹配。 So to achieve similar setup as in your screenshot, create an ampty project, and import the modules "core", "model".因此,要实现与屏幕截图类似的设置,请创建一个 ampty 项目,然后导入模块“core”、“model”。 .. to it. .. 到它。

Then open the "File > Project Structure" and check and adjust each module's "sources" and "test sources' folder. Make sure no source or test source overlap (this is the reason you got the "cannot save settings" error).然后打开“文件>项目结构”并检查并调整每个模块的“源”和“测试源”文件夹。确保没有源或测试源重叠(这就是您收到“无法保存设置”错误的原因)。

See for example the screenshot below.例如,请参见下面的屏幕截图。 The project is called "test" and is in "C:\\Projects\\test".该项目称为“test”,位于“C:\\Projects\\test”中。 The module "springapp" is in "C:\\Projects\\test\\springapp", its sources are marked "C:\\Projects\\test\\springapp\\src", its test sources are "C:\\Projects\\test\\springapp\\test".模块“springapp”在“C:\\Projects\\test\\springapp”中,其源标记为“C:\\Projects\\test\\springapp\\src”,其测试源为“C:\\Projects\\test\\springapp\\test ”。 The same for the other modules.其他模块也一样。

Especially note that no one of the modules marks the root folder "C:\\Projects\\test\\" as a "sources" or "test sources" (As I wrote above this is the reason for the error you got).特别要注意的是,没有任何模块将根文件夹“C:\\Projects\\test\\”标记为“源”或“测试源”(正如我上面写的,这就是你得到错误的原因)。

在此处输入图片说明

在项目设置中,您可以“添加内容根”。

File -> Project Structure -> Modules (On left panel) -> + (addition sign) -> import module -> choose module with file chooser -> import recursively -> apply and ok.文件 -> 项目结构 -> 模块(左侧面板) -> +(加号) -> 导入模块 -> 使用文件选择器选择模块 -> 递归导入 -> 应用并确定。 That should do it那应该这样做

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

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