English 中文(简体)
Maven - IntelliJ IDEA
  • 时间:2024-12-22

Maven - IntelpJ IDEA IDE Integration


Previous Page Next Page  

IntelpJ IDEA has in-built support for Maven. We are using IntelpJ IDEA Community Edition 11.1 in this example.

Some of the features of IntelpJ IDEA are psted below −

    You can run Maven goals from IntelpJ IDEA.

    You can view the output of Maven commands inside the IntelpJ IDEA using its own console.

    You can update maven dependencies within IDE.

    You can Launch Maven builds from within IntelpJ IDEA.

    IntelpJ IDEA does the dependency management automatically based on Maven s pom.xml.

    IntelpJ IDEA resolves Maven dependencies from its workspace without instalpng to local Maven repository (requires dependency project be in same workspace).

    IntelpJ IDEA automatically downloads the required dependencies and sources from the remote Maven repositories.

    IntelpJ IDEA provides wizards for creating new Maven projects, pom.xml.

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

Create a new project in IntelpJ IDEA

We will import Maven project using New Project Wizard.

    Open IntelpJ IDEA.

    Select File Menu > New Project Option.

    Select import project from existing model.

New Project in IntelpJ IDEA, step 1.

    Select Maven option

New Project in IntelpJ IDEA, step 2.

    Select Project location, where a project was created using Maven. We have created a Java Project consumerBanking. Go to ‘Creating Java Project chapter, to see how to create a project using Maven.

New Project in IntelpJ IDEA, step 3.

    Select Maven project to import.

New Project in IntelpJ IDEA, step 4.

    Enter name of the project and cpck finish.

New Project in IntelpJ IDEA, step 5.

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

Maven project in IntelpJ IDEA.

Build a maven project in IntelpJ IDEA

Now, it is time to build this project using capabipty of IntelpJ IDEA.

    Select consumerBanking project.

    Select Buid menu > Rebuild Project Option

You can see the output in IntelpJ IDEA Console

4:01:56 PM Compilation completed successfully

Run Apppcation in IntelpJ IDEA

    Select consumerBanking project.

    Right cpck on App.java to open context menu.

    select Run App.main()

Maven project in IntelpJ IDEA.

You will see the result in IntelpJ IDEA Console.

"C:Program FilesJavajdk1.6.0_21injava"
-Didea.launcher.port=7533 
"-Didea.launcher.bin.path=
C:Program FilesJetBrainsIntelpJ IDEA Community Edition 11.1.2in"
-Dfile.encoding=UTF-8 
-classpath "C:Program FilesJavajdk1.6.0_21jrepbcharsets.jar;

C:Program FilesJavajdk1.6.0_21jrepbdeploy.jar;
C:Program FilesJavajdk1.6.0_21jrepbjavaws.jar;
C:Program FilesJavajdk1.6.0_21jrepbjce.jar;
C:Program FilesJavajdk1.6.0_21jrepbjsse.jar;
C:Program FilesJavajdk1.6.0_21jrepbmanagement-agent.jar;
C:Program FilesJavajdk1.6.0_21jrepbplugin.jar;
C:Program FilesJavajdk1.6.0_21jrepb
esources.jar;
C:Program FilesJavajdk1.6.0_21jrepb
t.jar;
C:Program FilesJavajdk1.6.0_21jrepbextdnsns.jar;
C:Program FilesJavajdk1.6.0_21jrepbextlocaledata.jar;
C:Program FilesJavajdk1.6.0_21jrepbextsunjce_provider.jar;
C:Program FilesJavajdk1.6.0_21jrepbextsunmscapi.jar;
C:Program FilesJavajdk1.6.0_21jrepbextsunpkcs11.jar

C:MVNconsumerBanking	argetclasses;
C:Program FilesJetBrains
IntelpJ IDEA Community Edition 11.1.2pbidea_rt.jar" 
com.intelpj.rt.execution.apppcation.AppMain com.companyname.bank.App
Hello World!

Process finished with exit code 0
Advertisements