简体   繁体   中英

Intellij - Add project dependency like in Eclipse

I'm switching to Intellij and trying to do the same thing as in Eclipse. In Eclipse, you can add a project as a dependency in another project ( project properties -> "Java Build Path" -> "Projects" -> Click on my library project ).

The current situation is that I'm developing a library and I can test the features in another project without building the jar file every time I add new stuff to the library.

I'm trying to achieve this with Intellij but without success (the projects are both imported in Intellij).

How can I do that?

File > Project Structure. Then choose your module, and add any dependency, either Jar, Library or Module:

IntelliJ 截图

Larger image here: http://i.imgur.com/rjdxJHx.png

From File -> project structure, select Modules. You will be presented with all the added projects. Click a project and from the right hand side select Dependencies tab. This will show you projects that are not imported in red coloured text. HTH

File > Project Structure > Project Settings > Modules

项目结构

  1. Add the module you want to add as dependency.
  2. Add your module dependency in your project.

If you use Maven you'll see the following message:

Module 'your-module' is imported from Maven. Any changes made in its configuration may be lost after reimporting.

→ Add your project to your pom.xml

If you don't do that, your dependency will be removed each time you reimport/refresh maven projects.

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