Importing an existing Maven Project into Intellij

ยงImporting an existing Maven project into IntelliJ

If you worked through the command line example for Maven, you have a Maven project that you can integrate into Intellij IDEA Using built in IntelliJ Maven support. Before integrating your project, make sure that your IntelliJ Settings use the following:

  • Maven 3.3 or higher
  • A JDK 1.8 or higher

Note When developing with Lagom you will often run several services in a single Java Virtual Machine. See how to increase Memory for Maven.

To integrate an existing Maven Java project into IDEA, follow these steps:

  1. Open IntelliJ IDEA and close any existing project.

  2. From the Welcome screen, click Import Project.
    The Select File or Directory to Import dialog opens.

  3. Navigate to your Maven project and select the top-level folder. For example, with a project named my-first-system:

  4. Click OK.
    The Import Project screen opens:

  5. For the Import project from external model value, select Maven and click Next.

  6. Select Import Maven projects automatically and leave the other fields with default values.

  7. Click Next.
    Your Maven project should be selected for import:

  8. Click Next.
    The Please select project SDK screen opens.

  9. Make sure the correct JDC is selected and click Next.

  10. Change the project name and location if you like, and click Finish.

  11. Create a run configuration to test your project:

    1. From the Run menu, select Run.
    2. Click Edit Configurations….
    3. Make sure Maven is selected, and click + (Add New Configuration).
    4. Select Maven.
    5. Give your configuration a name.
    6. In the Comand line: field, enter lagom:runAll.
    7. Click OK.
  12. Build your project and run it using the configuration you created.
    The console displays the following when Lagom is running:

  13. Verify that the services are indeed up and running by invoking the hello service endpoint from any HTTP client, such as a browser:

    http://localhost:9000/api/hello/World
    

    The request returns the message Hello, World!.

Found an error in this documentation? The source code for this page can be found here. Please feel free to edit and contribute a pull request.