1, open Eclipse4.2, create a new MAVEN project
1 Select Maven's archetype as Maven-archetype-webapp
2) Fill in the project information
2, improve the project directory structure
1 manually add Src/main/java, Src/test/java, and Src/test/resource three Source folder, right-click on the item New---->source folder, enter folder name.
2 Modify the source folder's compile path, enter the Java Build Bath window, double-click the output folder under each file, and specify the path.
Src/main/java and Src/main/resource Specify Target/calsses,
Src/test/java and Src/test/resource Specify target/test-classes
Select the selected allow output folders for source folders.
3. Convert the project to Dynamic Web Module
1 Right click on the item, select Properties, then select Project Facets, then click Convert to Faceted form ...
Check dynamic Web Module, select 3.0 to support servlet3.0
Check Java, select 1.6 or higher JDK version
Then click further configuration available ... and in the pop-up window, context directory input: Src/main/webapp
2 Configure the deployment of the program deployment Assembly, delete the test of the two items, test program released when not needed, add Maven dependency library, Eclipse release can be published to the Lib directory
3) Delete Jdk5, add jdk6
4, Pom.xml file configuration, add Servlet3 dependencies, log configuration, etc.
<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>cn.luxh.app</groupId> <artifactid>app</artifactid > <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>app Maven Web App</name> <url>http://maven.apache.org</url> <!--property configuration--> <properties> <pro Ject.build.sourceencoding>utf-8</project.build.sourceencoding> <junit.version>4.10</ Junit.version> <logback.version>1.0.7</logback.version> <slf4j.version>1.7.2</slf4j.ve Rsion> </properties> <!--dependency configuration--> <dependencies> <dependency> <gro Upid>junit</groupid> <artifactid>junit≪/artifactid> <version>${junit.version}</version> <scope>test</scope> & lt;/dependency> <dependency> <groupId>javax.servlet</groupId> <artifactid>j
Avax.servlet-api</artifactid> <version>3.1-b02</version> <type>jar</type> <scope>provided</scope> </dependency> <dependency> <groupid>org.slf4j& Lt;/groupid> <artifactId>slf4j-api</artifactId> <version>${slf4j.version}</version > </dependency> <dependency> <groupId>ch.qos.logback</groupId> <arti Factid>logback-core</artifactid> <version>${logback.version}</version> </dependency>
; <dependency> <groupId>ch.qos.logback</groupId> <artifactid>logback-classic</art
Ifactid> <version>${logback.version}</version> </dependency> </dependencies> <build> &L t;finalname>demo</finalname> <plugins> <plugin> <groupid>org.apache.mav En.plugins</groupid> <artifactId>maven-compiler-plugin</artifactId> <version&
Gt;2.5.1</version> <configuration> <source>1.6</source>
<target>1.6</target> </configuration> </plugin> </plugins> </build> </project>
5, logback.xml log file configuration, the file is stored in the src/main/resources/directory
<?xml version= "1.0" encoding= "UTF-8"?>
<configuration>
<!--console output-->
Name= "stdout" class= "Ch.qos.logback.core.ConsoleAppender" >
<encoder>
<pattern>%date [% Thread]%-5level%logger{80}-%msg%n</pattern>
</encoder>
</appender>
<root level = "INFO" >
<appender-ref ref= "stdout"/>
</root>