Create MAVEN projects with Eclipse and generate Meta-inf and Web-inf directories

Source: Internet
Author: User
1. Create a Web project using the Eclipse plug-in

First create a MAVEN project like the following diagram

We checked on create a simple project (no skeleton is used)

The packing here chooses the form of war

Since packing is a war package, there are more WebApp directories below.
2. Since our project is to be published under Tomcat by using Eclipse, here we need to turn the project into Dynamic Web project

Right-click on our project, select Properties and find Project Facets, and click Convert to faceted form ... The following figure:

Then check the dynamic Web Module and click OK as follows: (3 only TOMCAT7 support, under the partial IDE can continue to switch versions, such as replacement to the 3.1 standard servlet)

Next, look at our project structure and have a Web content catalog

Note:
1 if the dynamic WEB module option is not present when the structure is converted, refer to my previous blog post.
2 If the above folder is not automatically generated, the effect of manual creation is the same, no need to worry. 3, although we can post to Tomcat at this time, but this does not conform to the MAVEN structure, we have to do the following modifications

Put the above figure webcontent two directory meta-inf, Web-inf directly cut to Src/main/webapp directory, and delete the WebContent directory, then the current project structure as shown below:

Then we want to modify the publishing rules, right click on the item, select Deployment Assembly

Select WebContent, remove it, test class We also do not need to publish, test two directory pages can remove

Then reassign the path of a Web, click Add, select Folder–〉next

Find the WebApp directory under SRC, then finish

In the final step, we'll point the current build path to Maven Dependency, click Add, select Java Build path Entries and then next

Note: The Maven dependency option can only be found after the MAVEN project has added dynamic Web module. If this option is not found, the MAVEN project you created has not yet been translated into a Web project.

After the completion of the following figure:

Note:
The paths that appear in most of the blogs circulated online are as follows
/src/main/webapp/
/src/main/java/web-inf/classes
/src/main/resources/web-inf/classes
Maven Dependencies/web-inf/lib

I think I've wasted a lot of time watching this blog. I've always wanted to add one in front of the image above,
and it's not like a blog that's been circulated for most of the Internet./

/src/main/webapp    /   This phrase has already provided a root path for our web project, The other paths are relative paths based on the root path. So no need to add in front

Finally attach the Maven jar package dependencies. Reference to the second kill system of MU-class network

<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.seckill</groupId> <artifactid>seckill </artifactId> <version>0.0.1-SNAPSHOT</version> <name>seckill</name> <url> Http://maven.apache.org</url> <properties> <project.build.sourceencoding>utf-8</ project.build.sourceencoding> </properties> <dependencies> <dependency> <groupid&gt ;junit</groupid> <artifactId>junit</artifactId> <version>4.11</version> &L T;scope>test</scope> </dependency> <!--complement project dependent--> <!--log--> <dependency > <groupId>org.slf4j</groupId> &LT;ARTIFACTID&Gt;slf4j-api</artifactid> <version>1.7.12</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-core</artifactId> <vers ion>1.1.1</version> </dependency> <dependency> <groupid>ch.qos.logback</groupi d> <artifactId>logback-classic</artifactId> <version>1.1.1</version> </depen dency> <!--database dependency--> <dependency> <groupId>mysql</groupId> <artifact Id>mysql-connector-java</artifactid> <version>5.1.35</version> <scope>runtime</s cope> </dependency> <dependency> <groupId>c3p0</groupId> <artifactId>
     C3p0</artifactid> <version>0.9.1.2</version> </dependency> <!--DAO Framework dependencies-->
<dependency>      <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3
      .3.0</version> </dependency> <dependency> <groupId>org.mybatis</groupId>

    <artifactId>mybatis-spring</artifactId> <version>1.2.3</version> </dependency> <!--servlet Web dependencies--> <dependency> <groupId>taglibs</groupId> <artifactid
      >standard</artifactId> <version>1.1.2</version> </dependency> <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> <version>1.2</ver
      sion> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.5.4</version> &LT;/DEPENDENCY&G
    T <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <versio N>3.1.0</version> </dependency> <!--spring dependencies--> <dependency> &LT;GROUPID&G T;org.springframework</groupid> <artifactId>spring-core</artifactId> <version>4.1.7.re lease</version> </dependency> <dependency> <groupid>org.springframework</groupid&
      Gt <artifactId>spring-beans</artifactId> <version>4.1.7.RELEASE</version> &LT;/DEPENDENCY&G
    T <dependency> <groupId>org.springframework</groupId> <artifactid>spring-context</art ifactid> <version>4.1.7.RELEASE</version> </dependency> <dependency> <g Roupid>org.springframework</groupid> <artifactId>spring-jdbc</artifactId> <version>4.1.7.release</version> </dependency> <dependency> <groupId>org.springframework< /groupid> <artifactId>spring-tx</artifactId> <version>4.1.7.RELEASE</version> & lt;/dependency> <dependency> <groupId>org.springframework</groupId> &LT;ARTIFACTID&G t;spring-web</artifactid> <version>4.1.7.RELEASE</version> </dependency> <depende
      Ncy> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>4.1.7.RELEASE</version> </dependency> <dependency> <groupid>or G.springframework</groupid> <artifactId>spring-test</artifactId> <version>4.1.7.releas
 e</version> </dependency> </dependencies> </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.