Reprint:http://blog.csdn.net/smilevt/article/details/8215558/
Build a Web project using the Eclipse maven
1. Select Build Maven Project Choose File--new--and other, select Maven---MAVEN project in the new window; click Next
2. Select the project path usedefault Workspace location default workspace
3. Select the project type select Maven-archetype-webapp in the Artifact ID
4. Enter the group ID and Artifact ID, and the package
Group IDs generally write large project names. The Artifact ID is the child project name.
Package is the default for you to build a bag, do not write or can
5, the newly established file structure such as
If there is more content displayed here, it is generally the problem of filters setting, or perspective Java EE mode, it can be
6, configuration items need to add Src/main/java,src/test/java, src/test/resources three folders. Right-click the project root to create these three folders by clicking New---Source folder
Note: Instead of building a regular folder, source folder
7. Change the class path right-click Project, there should be 4 folders under Java Build path, Source. Src/main/java,src/main/resources,src/test/java, Src/test/resources
Select the Allow output folders for source folders
Double-click the output folder for each of the folders to select the path
Src/main/java,src/main/resources, choose target/classes;
Src/test/java, src/test/resources, choose target/test-classes;
Here you also change: Change the order in which folders are displayed: Click order and Export; change JDK version: Double-click the JRE System Library in libraries to version 1.6
8, turn the project into a Dynamic Web project right-click Project, select Project Facets, click Convert to Faceted fro
9. Configure project Facets to change the version of the dynamic Web module to 2.3. (3.0 for Java7).
If you are prompted with an error, you may need to set compiler compliance level to 1.6 in Java compiler, or change the Java version of this window to 1.6
10. Set deployment assembly (Web Deployment Assembly)
After the above steps are set up, clicking the Ok,properties window will close and open this window in the right-click Project. A deployment Assembly appears in the list on the left, click to enter, as
The list here is the path to the file publication when the project is deployed.
(1) We delete the two items of test, because tests are used for testing and do not need to be deployed.
(2) Set the Maven jar package to be published under Lib.
ADD, Javabuild Path Entries, Maven Dependencies, Finish
Setup Complete
11. Build framework Add the required jar packages to the Pom.xml
Using Maven POM Editor to open the Pom.xml file in the project, select Dependencies, click Add in the Dependencies column, first pop up a search button, such as JSF, will automatically search for JSF-related jar packages, We chose JSF in the 2.0.4 version to add all the JSF packages in.
Additional jar packages that need to be added are: JUnit, Jstl
or click Pom.xml directly edit the Pom.xml file, so you can copy directly to dependencies content;
Our pom.xml files can be copied directly to the following content:
<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/maven-v4_0_0.xsd" >
<modelVersion>4.0.0</modelVersion>
<groupId>com.smile.maven.demo</groupId>
<artifactId>maven-demo-web</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>maven-demo-web maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.0.4-b09</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
Version>2.0.4-b09</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>
<build>
<finalName>maven-demo-web</finalName>
</build>
</project>
12, release to the engineering point right-click: Run as->maven install and then run as--mavenpackage.
When you're done, run with Tomcat.
Eclipse builds a MAVEN Web project