Build a Maven project using eclipse
1. Install the m2eclipse plug-in
To build a Maven project using eclipse, We need to install the meeclipse plug-in first.
Click "Help-> eclipse marketplace" in the eclipse menu bar to search for the plug-in Maven integration for eclipse and click "Install", as shown in:
After the installation is complete, click File> New> Other In the eclipse menu bar. The displayed dialog box is as follows:
2. Build a Maven Project
Take eclipse3.6 as an Example
1) create a simple Maven Project
On the eclipse menu bar, choose File> New> ohter> maven. The following dialog box is displayed:
Select the maven project and click Next. In the next dialog box, click Next. The following dialog box is displayed.
Operation, select Maven-Archetype-Quickstart, and click Next
Enter groupid, artfactid, version, and other information as shown in the following figure. Click Finish.
Therefore, we have successfully created a simple Maven project and project structure.
2) create a Maven WEB Project
Similar to creating a simple Maven project, choose File> New> Other> Maven project from the eclipse menu.
On the maven-Archetype page, perform the following operations:
Click Next, fill in the corresponding groupid, artifactid, version, and other information, and click Finish
Shows the maven web project structure:
Right-click the project and choose Properties> Project facets.
As you can see, the project is web2.3 java1.5. Of course, we can also change it to the version we need to open the XML file my-app-Web /. settings/org. eclipse. WST. common. project. facet. core. XML:
XML Code
- <? XML version = "1.0" encoding = "UTF-8"?>
- <Faceted-Project>
- <Fixed facet = "WST. jsdt. Web"/>
- <Installed facet = "Java" version = "1.5" type = "codeph" text = "/codeph"/>
- <Installed facet = "JST. Web" version = "2.3" type = "regxph" text = "yourobjectname"/>
- <Installed facet = "WST. jsdt. Web" version = "1.0"/>
- </Faceted-Project>
3) import the maven Project
Right-click Eclipse project explorer and select import in the pop-up box, as shown in:
Select existing Maven projects and click Next. The displayed dialog box is displayed:
Select a created Maven project and click Finish.
Therefore, the maven project is imported successfully.
3. Run the maven command
Right-click the project and click Run as, for example:
You can see many existing Maven commands, click to run them, and you can see the running information on the console.
If the maven command you want to run is not found here, click Maven build to create a new command, as shown in:
Enter the maven command and click Run.
The newly added Maven command can be found as follows and run again: