create MAVEN projects with Eclipse and generate Meta-inf and Web-inf catalogs
1. Create a Web project using the Eclipse plugin
Start by creating a Maven project as shown below
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.
2. 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 ... The following figure:
Then tick the dynamic Web Module and click OK as follows: (3 only TOMCAT7 support, under some IDE can continue to switch versions, such as the replacement of the 3.1 standard servlet)
Next, we look at our project structure, and we have one more Web content directory
Note:
1) If the Dynamic WEB module option does not appear when the structure is converted, you can 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 publish to Tomcat at this time, but this does not conform to the structure of MAVEN, we have to make the following changes
Put the above figure webcontent the following two directory Meta-inf, Web-inf directly cut into the Src/main/webapp directory, and delete the WebContent directory, then the current project structure as follows:
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
Note: The MAVEN dependency option will not be found until the MAVEN project has added the dynamic Web module. If this option is not found, the MAVEN project you created has not been converted to a Web project.
After the completion of the following image:
Note:
The paths that appear in most of the blogs that are circulating online are as follows
/src/main/webapp/
/src/main/java/web-inf/classes
/src/main/resources/web-inf/classes
Maven Dependencies/web-inf/lib
Look at this blog post I think I wasted a lot of time. I always want to be in front of the image above and add a/
actually not like most of the blog on the Internet as the front will have/
/src/main/webapp / This sentence has provided the root path for our web project, The other paths are relative paths based on the root path. So there is no need to add/
1 2 3) 4 5
Finally, the Maven jar package dependency is attached. The second kill system of the 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> ;junit</groupid> <artifactId>junit</artifactId> <version>4.11</version> &L T;scope>test</scope> </dependency> <!--complete Project dependency--<!--log--<dependency > <groupId>org.slf4j</groupId> <ARTIFACTID≫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 Dependent--<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 Dependency--
<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-related 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> </DEPENDENCY&G
T <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <versio N>3.1.0</version> </dependency> <!--spring Dependency--<dependency> <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> </DEPENDENCY&G
T <dependency> <groupId>org.springframework</groupId> <artifactid>spring-context</art Ifactid> <version>4.1.7.release</version