Requirement: Create a servlet version 3.0,java version is 1.7 maven Web project
Create an environment:
System: Window 7
Software: Eclipse, Maven
To create a step:
1. Create a MAVEN project using the Eclipse tool and specify where the project is stored
2. Choose to create a Web project and set the project's group ID, Artifact ID, package information
3. Click Finish to generate the MAVEN Web project, project structure such as
Not expanded:
Expand Diagram:
In accordance with the above steps to create the MAVEN project, we also need to make the following changes to avoid garbled to do the following settings:
To solve the index.jsp error, we need to introduce the Java EE Jar report. Introduced in Pom.xml:
1 <!--import java EE jar package (can remove index.jsp error)--2 <dependency>3 < Groupid>javax</groupid>4 <artifactId>javaee-api</artifactId>5 <version>7.0</version>6 </dependency>
Configuration items:
Because the project was created by the wizard, the servlet version of the project is 2.3,java version 1.5, so the project needs to be reconfigured:
1. Under the main file, create a new Java file
2, modify the JDK, right-click the project, select Properties, set to use JDK 1.7
After determining the project structure changes to
3. Modify the Web. XML configuration file
1 <?xml version= "1.0" encoding= "UTF-8"?> 2 <web-app xmlns:xsi= "http://www.w3.org/2001/ Xmlschema-instance " 3 xmlns=" Http://java.sun.com/xml/ns/javaee " 4 xsi:schemalocation="/http/ Java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd " 5 id=" webapp_id "version=" 3.0 "> 6 <display-name>test-hd-</display-name> 7 <welcome-file-list> 8 <welcome-file>index.jsp</welcome-file> 9 </welcome-file-list> </ Web-app>
4, modify the Org.eclipse.wst.common.project.facet.core.xml
5. Modify the file Org.eclipse.jdt.core.prefs
To publish a startup project:
1. Publish to Tomcat and launch Tomcat
2. Deployment
3. Modify URL access (not required)
4, launch Tomcat, the browser access URL is: Http://localhost:8080/hongzmMaven
Create complete
When you view the Eclipse console console, the error is as follows:
Warning: [Setpropertiesrule]{server/service/engine/host/context} Setting Property ' source ' to ' org.eclipse.jst.jee.server : Hongceshi ' did not ' find a matching property.
This warning occurs because Tomcat does not support the Source property in the Server.xml context node
workaround : Double-click the 1th of step 3rd (modify URL access) and check the "Publish module contexts to separate XML files" option below the server options.
The main purpose of this is to make an element that would have been configured in Conf/server.xml, separate (detached) to/conf/catalina/localhost/in a directory that specifically generates a {context_name}.xml.
"Maven" Eclipse creates Java Web project with maven (i)