First of all, my myeclipse version is stable 2.0, and there are two common ways to create MAVEN projects in MyEclipse, namely:
- New Maven Project
- New Web Project & Add maven Support
the right posture is the second type! Because the first is created by a web-app skeleton of the archetype plug-in, The version is lower (j2ee1.3), the modification debugging problem is also a lot of problems, before I also made a lot of inexplicable problems, and MyEclipse founder Genuitec also mentioned in their official documents in the use of this way to create a MAVEN project:Creating After Maven Projects in MyEclipse, clear the direction, the next step is to create a MAVEN Web project complete :
- Create a Java EE Web Project
Select the Jdk1.7,java EE version to select 6.0 (Servlet 3.0) According to the project requirements, so as to ensure that the Web. XML is generated with a 3.0 header, and that the dependency on the Java EE can be selected later instead of manually adding dependency to the POM.
Note here tick generate Web. XML deployment descriptor to generate the Web. xml file.
Enter the MAVEN coordinates as shown, and select the standard MAVEN JEE Project structure (structure).
- Configure Maven Dependencies
Note that the dependency of the Java EE and Jstl is not selected, the relevant Servlet-api is added by ourselves in the Pom, finally click Finish to complete the project creation, we create a good project structure as follows:
You can see that the directory structure is very standard and nice, even the location of the output folder to help us specify (Target/classes and target/test-classes). Finally add Servlet-api and Jstl dependencies in the POM, compile plug-ins and war plug-ins have also helped us to generate a good, complete pom file as follows:
<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.firstelite</groupId> <artifactid>web-test-maven</ artifactid> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <name>w eb-test-maven</name> <description/> <properties> <project.build.sourceencoding>utf-8 </project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.0.1</version> </dependency> <dependency> <groupid>javax. Servlet</groupid> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> </dependencies> <build> <plugins> <plugin> <artifactid>maven-compiler -plugin</artifactid> <version>2.3.2</version> <configuration> <source>1.7</source> <target>1.7</target> </conf iguration> </plugin> <plugin> <artifactid>maven-war-plugin</a rtifactid> <version>2.2</version> <configuration> &L T;version>3.0</version> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> </plugins> & Lt;/build></project>
Reference: http://blog.csdn.net/wlwlwlwl015/article/details/50570288
MyEclipse2015 Creating a Configuration Web+maven Project