How to Use maven to build a web project and maven to build a web project

Source: Internet
Author: User

How to Use maven to build a web project and maven to build a web project

It has been registered in the blog Park for more than 20 days and has not yet written a blog. Today, I will publish an article to facilitate searching for notes later.

I have personally developed java web for several years. Since my company is a business-type company, I use old and stable technologies and have little access to new content,

After several years of hard work, our technical capabilities have been gradually eliminated by the times. In order to survive in the great waves taosha, we need to make a good effort, start from the basic content, accumulate steadily, and update our technical libraries.

I don't want to eat a big fat man, I just want to make a little progress every day.

Let's get down to the truth. How to build a web project using maven?

Step 1: first create a maven Project

The Created directory structure is as follows:

This directory structure is not what we want, so we need to change it.

Step 2: Adjust the directory structure

1. Right-click the Project and choose properties> Project Facets. Remove the check box in front of the red box and save

2. Check the link again.

3. Click this link, set it on the pop-up page, and click OK.

 

4. Select Deployment Assembly

 

 

The modified directory structure is as follows:

 

 

Step 3: configure the pom. xml file and add web Dependencies

<Project xmlns = "http://maven.apache.org/POM/4.0.0" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schemaLocation = "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion> 4.0.0 </modelVersion> <groupId> com. ssh </groupId> <artifactId> mvn-ssh </artifactId> <version> 0.0.1-SNAPSHOT </version> <packaging> war </packaging> <dependencies> <! -- Servlet basics --> <dependency> <groupId> javax. servlet </groupId> <artifactId> servlet-api </artifactId> <version> 3.0-alpha-1 </version> <scope> provided </scope> </dependency> <dependency> <groupId> javax. servlet </groupId> <artifactId> jstl </artifactId> <version> 1.2 </version> </dependency> </dependencies> </project>

Step 4: Check whether the web environment is accessible

1. Create a jsp page

 

 

2. Configure the web. xml file

    <welcome-file-list>        <welcome-file>index.jsp</welcome-file>    </welcome-file-list>

 

3. start tomcat and access

 

Now, maven is used to build a web project.

 

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.