IntelliJ IDEA has inbuild support for Maven. We’re using IntelliJ IDEA Community Edition 11.1 in this example.

Some of features of IntelliJ IDEA are listed below

  • You can run Maven goals from IntelliJ IDEA.
  • You can can view the output of Maven commands inside the IntelliJ IDEA using its own console.
  • You can update maven dependencies within IDE.
  • You can Launch Maven builds from within IntelliJ IDEA.
  • IntelliJ IDEA does the dependency management automatically based on Maven’s pom.xml.
  • IntelliJ IDEA resolves Maven dependencies from its workspace without installing to local Maven repository (requires dependency project be in same workspace).
  • IntelliJ IDEA automatic downloads required dependencies and sources from the remote Maven repositories.
  • IntelliJ IDEA provides wizards for creating new Maven projects, pom.xml

Following example will help you to leverage benefits of integrating IntelliJ IDEA and Maven.

Create a new project in IntelliJ IDEA

We’ll import Maven project using New Project Wizard.

  • Open IntelliJ IDEA.
  • Select File Menu > New Project Option.
  • Select import project from existing model.

New Project in IntelliJ IDEA, step 1.

  • Select Maven option

New Project in IntelliJ IDEA, step 2.

  • Select Project location, where a project was created using Maven. We’ve create a Java Project consumerBanking.See Maven Creating Project to see how to create a project using Maven.

New Project in IntelliJ IDEA, step 3.

  • Select Maven project to import.

New Project in IntelliJ IDEA, step 4.

  • Enter name of the project and click finish.

New Project in IntelliJ IDEA, step 5.

Now, you can see the maven project in IntelliJ IDEA.Have a look at consumerBanking project external libraries.You can see that IntelliJ IDEA has added Maven dependencies to its build path under Maven section.

Maven project in IntelliJ IDEA.

Build a maven project in IntelliJ IDEA

Now, Its time to build this project using capability of IntelliJ IDEA.

  • Select consumerBanking project.
  • Select Buid menu > Rebuild Project Option

You can see the output in IntelliJ IDEA Console

4:01:56 PM Compilation completed successfully

Run Application in IntelliJ IDEA

  • Select consumerBanking project.
  • Right click on to open context menu.
  • select Run App.main()

Maven project in IntelliJ IDEA.

You will see the result in IntelliJ IDEA Console.

"C:Program FilesJavajdk1.6.0_21binjava"
C:Program FilesJetBrainsIntelliJ IDEA Community Edition 11.1.2bin"
-classpath "C:Program FilesJavajdk1.6.0_21jrelibcharsets.jar;
C:Program FilesJavajdk1.6.0_21jrelibdeploy.jar;
C:Program FilesJavajdk1.6.0_21jrelibjavaws.jar;
C:Program FilesJavajdk1.6.0_21jrelibjce.jar;
C:Program FilesJavajdk1.6.0_21jrelibjsse.jar;
C:Program FilesJavajdk1.6.0_21jrelibmanagement-agent.jar;
C:Program FilesJavajdk1.6.0_21jrelibplugin.jar;
C:Program FilesJavajdk1.6.0_21jrelibresources.jar;
C:Program FilesJavajdk1.6.0_21jrelibrt.jar;
C:Program FilesJavajdk1.6.0_21jrelibextdnsns.jar;
C:Program FilesJavajdk1.6.0_21jrelibextlocaledata.jar;
C:Program FilesJavajdk1.6.0_21jrelibextsunjce_provider.jar;
C:Program FilesJavajdk1.6.0_21jrelibextsunmscapi.jar;
C:Program FilesJavajdk1.6.0_21jrelibextsunpkcs11.jar
C:Program FilesJetBrains
IntelliJ IDEA Community Edition 11.1.2libidea_rt.jar"
Hello World!

Process finished with exit code 0


Enhanced by Zemanta

Leave a Reply

Your email address will not be published. Required fields are marked *