How to create a Web project with MAVEN (concrete steps)

Source: Internet
Author: User

Create a Web project with the Eclipse plugin to first create a MAVEN project such as

We tick on create a simple project (do not use skeleton)

Here's packing choose the form of the war

Since packing is a war package, there are more WebApp directories below.

Since our project is going to use eclipse to post to Tomcat, here we need to first turn the project into Dynamic Web project

Right-click on our project, select Properties and find Project Facets, and click Convert to faceted form ... Such as:

Then tick the dynamic Web Module and click OK such as: (3 only TOMCAT7 support)

Next, we look at our project structure, and we have one more Web content directory

Although we can publish to Tomcat at this point, but this does not conform to the structure of MAVEN, we have to make the following changes to the webcontent below the two directory Meta-inf, Web-inf directly cut into the Src/main/webapp directory, and delete the WebContent directory, then the current project structure such as:

Then we have to modify the publishing rules, right click on the project, select Deployment Assembly

Choose WebContent, remove it, test class we do not need to publish, the test of the two directory page can be removed

Then re-specify a Web path, click Add, select Folder--〉next

Locate the WebApp directory under SRC, and then finish

In the final step, we will point the current build path to Maven Dependency, click Add directly, choose Java Build path Entries and Next

Then click Finish to finish

After completion such as:

Now a maven-based WebApp is built and can be published directly from Eclipse into Tomcat

Add: We need to create a Web. XML under Src/main/webapp/web-inf

Import our spring MVC dependency jar Package

<dependencies>

<dependency>

<groupId>org.springframework</groupId>

<artifactId>spring-core</artifactId>

<version>3.0.7.RELEASE</version>

</dependency>

<dependency>

<groupId>org.springframework</groupId>

<artifactId>spring-web</artifactId>

<version>3.0.7.RELEASE</version>

</dependency>

<dependency>

<groupId>org.springframework</groupId>

<artifactId>spring-webmvc</artifactId>

<version>3.0.7.RELEASE</version>

</dependency>

<dependency>

<groupId>org.codehaus.jackson</groupId>

<artifactId>jackson-mapper-asl</artifactId>

<version>1.7.1</version>

</dependency>

</dependencies>

Original address: http://blog.csdn.net/chuyuqing/article/details/28879477

Save directly, MAVEN will automatically download the required jar file for us

How to create a Web project with MAVEN (concrete steps)

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.