Importing an existing Maven project in IntelliJ IDEA
While we can use IntelliJ IDEA to create a new project, in most cases you will already have an existing project in your filesystem. In the latter scenario, you will want to import this project.
Getting ready
As IntelliJ IDEA needs a Java environment to run, let us first ensure that the Java environment is set up on our system:
Ensure the project SDK is set to your Java installation.
How to do it...
To import an existing Maven project in IntelliJ IDEA, perform the following steps:
Start IntelliJ IDEA.
ChooseImport Project. Browse for the simple project that we created earlier:
Make changes if required. The changes can be made as shown in the following screenshot:
Confirm the project to be imported:
You are done! The existing Maven project is now imported to IntelliJ IDEA.
How it works...
IntelliJ IDEA has first-class support for Maven. It can parse pom files to determine the project structure and dependencies, and lay them out in the IDE.
Once the project is opened in IntelliJ IDEA, the following folders and files get created:
There's more...
All Maven-related operations can be conducted from the IDE by opening the Maven Projects tab in IntelliJ IDEA:
You can choose Lifecycle and click on the phase to be run. For instance, in the preceding screenshot, we run the package phase of the Lifecycle.