As described earlier how to install M2eclipse, we now use M2ecilpse to import the Hello World project.
Select the menu item File, and then select Import, and we'll see an Import dialog box where you can select Maven Projectsunder the General directory and click Next , the Import Projects dialog box appears,
In the dialog box, click Browse ... Select the root directory of Hello World (that is, the directory that contains the Pom.xml file), and the Projects: section of the dialog box displays the MAVEN projects that the directory contains.
After clicking Finish, M2ecilpse will import the item into the current workspace, and after the import is complete, we can see the project in the Package Explorer view.
We see the main code catalog Src/main/java and the test code catalog Src/test/java The resource directory in Eclipse, and the structure of packages and classes is very clear, Of course pom.xml is always at the root of the project, and from this view we can even see the dependency Junit-4.7.jar of the project, whose actual location points to the MAVEN local repository (where I customized the MAVEN local warehouse address to D:\java\ Repository, the following sections describe how to customize the local warehouse location.
Create a MAVEN project
It's also easy to create a MAVEN project, choose menu Item--- new--and other, select Maven Projectunder Maven in the Pop-up dialog box, then click Next > , in the New Maven Project dialog box that pops up, we use the default options (don't choose the createa simple Project option so we can use Maven archetype) and click Next >, at this time M2eclipse will prompt us to choose a archetype, we choose maven-archetype-quickstart, then click Next >. Since M2eclipse is actually creating the project using the Maven-archetype-plugin plugin, this step is similar to the previous section where we used archetype to create the project skeleton, input GroupID, Artifactid, version, Package (We don't consider the properties for the time being),
Note that we use different artifactid and package in order not to create conflicts and confusion with the previously imported Hello World items. OK, click Finish,maven The project is created, and its structure is basically the same as the previous Hello World project that was imported.
3 Run the MVN command
We need to enter commands such as MVN clean install on the command line to perform the Maven build, there are corresponding functions in M2eclipse, right click on the MAVEN project or Pom.xml, and then select Run as, you can see the following common MAVEN commands:
Select the MAVEN command you want to execute to perform the appropriate build, and we can see the build output in the Eclipse console. One common problem here is that the default option does not have the MAVEN command we want to do? For example, the default with MVN test, but we want to execute MVN clean test, very simple, choose Maven buid ... With the custom maven Run command, enter the command we want to execute in the goals entry in the popup dialog box, such as clean test, set name, and click Run . And, the next time we choose mavenbuild, or use the shortcut key ALT + Shift + X, M to quickly perform MAVEN builds, the last configuration can be found directly in the history. Figure 3-5 is the interface for customizing the MAVEN Run command:
Customizing the MVN command in Eclipse
Summary
This chapter describes a Hello World project in as simple and detailed a way as possible, focusing on the basic content of the POM, the basic structure of the MAVEN project, and the basic MAVEN commands for building the project. Based on this, it also describes how to use archetype to quickly create a project skeleton. Finally, it's about importing, creating, and building maven projects in Eclipse and NetBeans.
http://misisipi.blog.163.com/blog/static/19843416320121271146083/
M2eclipse simple use, create Maven project, run MVN command (GO)