简体   繁体   中英

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. 在此处输入图片说明

Note: I cannot use maven

Steps I have followed created a "test project" and "test project 2"
-> opened test project project structure in cmd+; (shortcut in mac)
-> in project settings modules clicked on "+" and selected "import module" option
-> selected project 2

-> I got this error message stating that

cannot save settings, must not contain source root /test/src. The root belongs to module test`

This link is more confusing , could not understand much 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. So to achieve similar setup as in your screenshot, create an ampty project, and import the modules "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". 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". 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).

在此处输入图片说明

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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