Easy Tutorial
❮ Project Templates Maven Manage Dependencies ❯

Maven in Eclipse

Eclipse offers a great plugin called m2eclipse which integrates Maven with Eclipse.

In the latest Eclipse versions, Maven is included by default. To access it, open Windows -> Preferences, and you should see the following screen:

Here are some features of m2eclipse:

Importing a Maven Project into Eclipse

Now, you can see the Maven project in Eclipse.

Check the properties of the consumerBanking project, and you'll find that Eclipse has added all Maven dependencies to its build path.

Let's build the Maven project using Eclipse's build functionality.

Maven starts building the project, and you can see the output logs in Eclipse's console.

[INFO] Scanning for projects...
[INFO] -------------------------------------------------------------------
[INFO] Building consumerBanking
[INFO] 
[INFO] Id: com.companyname.bank:consumerBanking:jar:1.0-SNAPSHOT
[INFO] task-segment: [package]
[INFO] -------------------------------------------------------------------
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [surefire:test]
[INFO] Surefire report directory: 
C:\MVN\consumerBanking\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.companyname.bank.AppTest

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.047 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] [jar:jar] [INFO] ------------------------------------------------------------------- [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------- [INFO] Total time: 1 second [INFO] Finished at: Thu Jul 12 18:18:24 IST 2012 [INFO] Final Memory: 2M/15M [INFO] -------------------------------------------------------------------

Now, right-click on App.java and select the Run As option. Choose As Java App.

You will see the following result:

Hello World!
❮ Project Templates Maven Manage Dependencies ❯