English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Eclipse provides a good plugin m2eclipse , this plugin can integrate Maven and Eclipse together.
Maven is built-in in the latest Eclipse, we open it, Windows-> Preferences, if the following screen appears:
Below lists m2Some features of Eclipse:
The target file of Maven can be run in the Eclipse environment.
You can use its built-in console to directly view the output of Maven commands in Eclipse.
You can update Maven dependencies under the IDE.
You can use Eclipse to build Maven projects.
Eclipse implements automated dependency management based on Maven's pom.xml.
It resolves the dependencies between Maven and the Eclipse workspace without installing the local Maven repository (requires the dependent project to be in the same workspace).
It can automatically download the required dependencies and source code from the remote Maven repository.
It provides a wizard for creating a new Maven project, pom.xml, and enabling Maven support on existing projects.
It provides a quick search for dependencies in the remote Maven repository.
Open Eclipse
Select File > Import > option
Select Maven Projects and click the Next button.
Select the project path, which is the storage path when creating a project with Maven. Suppose we have created a project: consumerBanking. Through Maven Build Java Project Check how to use Maven to create a project.
Click the Finish button.
Now, you can see the Maven project in Eclipse.
Take a look at the properties of the consumerBanking project, you can find that Eclipse has already added all the dependencies of Maven to its build path.
Alright, let's use Eclipse's compilation feature to build this Maven project.
Right-click to open the context menu of the consumerBanking project
Select the Run option
Then select the maven package option
Maven starts building the project, you can see the output log in the Eclipse 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 App.java, select Run As Options. Select As Java App
You will see the following result:
Hello World!