Maven - Maven IntelliJ IDEA IDE Integration - maven tutorial
What are the features of IntelliJ IDEA ?
- IntelliJ IDEA has inbuild support for Maven. We're using IntelliJ IDEA Community Edition 11.1 .
- 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
![maven intelliJ idea ide integration](https://wikitechy.com/tutorials/maven/img/maven-images/maven-intellij-idea-ide-integration.gif)
learn maven tutorial - maven intellJ Idea IDE Integration - maven example maven intelliJ ide integration
Following example will help you to leverage benefits of integrating IntelliJ IDEA and Maven.
maven tutorial tags : apache maven , maven repository , maven central
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.
![maven integration newproject](https://wikitechy.com/tutorials/maven/img/maven-images/maven-integration-newproject.jpg)
learn maven tutorial - maven integration newproject - maven example
- Select Maven option
![select maven option](https://wikitechy.com/tutorials/maven/img/maven-images/select-maven-option.jpg)
learn maven tutorial - select maven option - maven example
- 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.
![Select Project location](https://wikitechy.com/tutorials/maven/img/maven-images/maven-integration-select.jpg)
learn maven tutorial - Select Project location in maven - maven example
- Select Maven project to import.
![Select Maven project to import](https://wikitechy.com/tutorials/maven/img/maven-images/maven-select-project.jpg)
learn maven tutorial - Select Maven project to import - maven example
- Enter name of the project and click finish.
![Enter name of the project and click finish](https://wikitechy.com/tutorials/maven/img/maven-images/maven-integration-consumer.jpg)
learn maven tutorial - maven project and click finish - maven example
- 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 integration select consumer bank](https://wikitechy.com/tutorials/maven/img/maven-images/maven-integration-consumer-bank.jpg)
learn maven tutorial - maven integration - maven example
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
Run Application in IntelliJ IDEA
- Select consumerBanking project.
- Right click on App.java to open context menu.
- select Run App.main()
![maven integration Run Application](https://wikitechy.com/tutorials/maven/img/maven-images/maven-consumer-banking.jpg)
learn maven tutorial - maven integration Run Application - maven example
- You will see the result in IntelliJ IDEA Console.
Output
"C:\Program Files\Java\jdk1.6.0_21\bin\java"
-Didea.launcher.port=7533
"-Didea.launcher.bin.path=
C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 11.1.2\bin"
-Dfile.encoding=UTF-8
-classpath "C:\Program Files\Java\jdk1.6.0_21\jre\lib\charsets.jar;
C:\Program Files\Java\jdk1.6.0_21\jre\lib\deploy.jar;
C:\Program Files\Java\jdk1.6.0_21\jre\lib\javaws.jar;
C:\Program Files\Java\jdk1.6.0_21\jre\lib\jce.jar;
C:\Program Files\Java\jdk1.6.0_21\jre\lib\jsse.jar;
C:\Program Files\Java\jdk1.6.0_21\jre\lib\management-agent.jar;
C:\Program Files\Java\jdk1.6.0_21\jre\lib\plugin.jar;
C:\Program Files\Java\jdk1.6.0_21\jre\lib\resources.jar;
C:\Program Files\Java\jdk1.6.0_21\jre\lib\rt.jar;
C:\Program Files\Java\jdk1.6.0_21\jre\lib\ext\dnsns.jar;
C:\Program Files\Java\jdk1.6.0_21\jre\lib\ext\localedata.jar;
C:\Program Files\Java\jdk1.6.0_21\jre\lib\ext\sunjce_provider.jar;
C:\Program Files\Java\jdk1.6.0_21\jre\lib\ext\sunmscapi.jar;
C:\Program Files\Java\jdk1.6.0_21\jre\lib\ext\sunpkcs11.jar
C:\MVN\consumerBanking\target\classes;
C:\Program Files\JetBrains\
IntelliJ IDEA Community Edition 11.1.2\lib\idea_rt.jar"
com.intellij.rt.execution.application.AppMain com.companyname.bank.App
Hello World!
Process finished with exit code 0