Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Apache Maven IntelliJ IDEA


May 26, 2021 Maven


Table of contents


Maven - IntelliJ IDEA

IntelliJ IDEA supports internal build capabilities for Maven. In this example, we use the intelliJ IDEA Community Edition 11.1 version.

Some of the features about IntelliJ IDEA are as follows:

  • Maven targets can be run through IntelliJ IDEA.
  • The output of the Maven command can be viewed in IntelliJ IDEA's own terminal.
  • Maven's dependencies can be updated in the IDE.
  • Maven's build can be started in IntelliJ IDEA.
  • IntelliJ IDEA implements automated management dependencies based .xml Maven's pom data.
  • IntelliJ IDEA can solve Maven's dependencies through its own workspace without having to install to the local Maven repository, although the projects that need to be dependent on are in the same workspace.
  • IntelliJ IDEA automatically downloads the required dependencies and source codes from the remote Maven repository.
  • IntelliJ IDEA provides a wizard for creating Maven .xml pom files.

The following examples will help you better understand the benefits of integrated IntelliJ IDEA and Maven.

Create a new project in IntelliJ IDEA

We'll use the New Project Wizard to import a Maven project.

  • Open IntelliJ IDEA.
  • Select the File Menu and New Project option.
  • Select the import project from the existing model option.

Apache Maven IntelliJ IDEA

  • Select the Maven option.

Apache Maven IntelliJ IDEA

  • Select the engineering path, which is the storage path when you create a project using Maven. S uppose we create a project: consumerBanking. Create a project with Maven - Create a project See how to create a project with Maven.

Apache Maven IntelliJ IDEA

  • Select the Maven project to import.

Apache Maven IntelliJ IDEA

  • Enter the name of the project and click "finish".

Apache Maven IntelliJ IDEA

So far, you can see the Maven project in IntelliJ IDEA. T ake a look at the Libraries and Test Libraries of the Consumer Banking Project. You can see that IntelliJ IDEA has added everything Maven relies on to its build path.

Apache Maven IntelliJ IDEA

Build a Maven project in IntelliJ IDEA

Well, let's build this Maven project using intelliJ IDEA's compilation capabilities.

  • Select the consumerBanking project.
  • Select the Buid menu and Rebuild Project option.

You can see the log of the build process output in intelliJ IDEA's terminal:

4:01:56 PM Compilation completed successfully

Run the application in IntelliJ IDEA

  • Select the consumerBanking project.
  • Right-click on the app .java pop up the context menu.
  • Select Run App.main(). .

Apache Maven IntelliJ IDEA

You will see the output of the results of the operation at the intelliJ IDEA terminal.

"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