Complete process for building Maven projects in Eclipse

Source: Internet
Author: User

The following steps are provided if you have already installed your local MAVEN library and the Maven plugin in eclipse (some of which are already integrated with the Maven plugin in eclipse)

First, the new MAVEN project

1, right mouse button---->new----->other ...

2. Click Next directly

3. Select Maven-archetype-webapp and click Next

4. Enter the basic package name of the project in the Group Id.

Enter the project name in the Artifact Id.

The value in Version is the default line, and no selection is made.

The package is written by default, and it can be written without a name.

Then click Finish to do it.

5. After creating the project, the structure is as follows:

6. Display the Missing directory

This step is strange, perhaps the bug of the Maven plugin in eclipse, it is better to do it, because the next step to create a new directory if the same name as the missing directory, will prompt the directory already exists error.

Right-click Project----->build Path----->configure BUild Path ...

Then in order and Export (here is the control item in the display order of the package) will find a few directories show missing (lost), randomly select a change in the next order (up or down or Top or Bottom), and then click Apply, OK, The missing directory is displayed in the project and once again into this place, the Red Cross logo has disappeared.

Directory structure after completion of operation

Ii. configuration of the MAVEN project

1, add the missing directory, MAVEN rules, you must create the following source Folder

Src/main/resources

Src/main/java

Src/test/resources

Src/test/java

Specific steps: Select Project-----> Right----->new----->other ...

The directory structure is basically complete at this time.

2. Configure Build Path

Right-click Project----->build Path----->configure BUild Path ...

(1) Set the output of 4 folders in source folder, double click to modify

Modify the output path separately to

/src/main/resources Correspondence Target/classes

/src/main/java Correspondence Target/classes

/src/test/resources Correspondence Target/test-classes

/src/test/java Correspondence Target/test-classes

I just need to change the fourth red box.

(2) Set up JDK for your own project in libraries

First remove the default j2se-1.5, via the Add Library ... Add your own JDK

Add a result after completion

3. Configuring the Web Deployment assembly (Web Deployment Assembly)

Right-click on the project, select Properties, select Deployment Assembly on the left

(1) Delete test two items because test is used for testing and does not need to be deployed.

(2) Set the Maven jar package to be published to Lib, if it is already there is no need to add.
ADD-----> Java Build Path Entries-----> Maven Dependencies-----> Finish

That's the end of it.

Iii. convert MAVEN projects to dynamic WEB project

(1) Right-click Project----->properties

On the left, select Project Facets, and click Convert faceted from

Modify the JDK version of Java for your current project, and tick before the Dynamic Web module (the version selection of the Dynamics Web modules is not very clear what the use, the current default), and finally click further Configuration available ... (Further available configuration) links

Below if the further Configuration available is not shown ... , you can remove the hook before the dynamic Web Module, click Apply, then fill the hook, then click Apply, General further Configuration available ... will show up.

To modify the value of content directory (webcontent) to Src/main/webapp, click OK, then go back to the previous window and click OK

(2) The next pom.xml in your project may make a mistake. Web. XML is missing and <failOnMissingWebXml> are set to True, if no error is reported, you can ignore it.

Workaround:

Creating a project using Maven sometimes failonmissingwebxml errors occur at the Pom.xml war, and according to Pom.xml you know that this project is a Web project and is packaged as a war package.

The error message is missing Web. XML, so if there is no web. XML in the project, add a Web. XML to the project and refresh the project, there should be no error.

If you are wrong, you need to Click Project----->clean above Eclispe to clean up the project.

The two-step error should have been cleared.

(3) In this step, the Web project is created, the directory structure

Complete process for building Maven projects in Eclipse

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.