Use MAVEN to manually create a web project and mavenweb Project
Problem: for example, when using maven to create a webapp project, the archetype maven-archetype-webapp is used by default. This archetype type is old and has the following Disadvantages:
1. The default project will report an error
The superclass "javax. servlet. http. HttpServlet" was not found on the Java Build Path index. jsp/demo/src/main/webapp line 1 JSP Problem
2. jdk 1.5 is used by default.
3. The Dynamic Web Module version is 2.3.
Therefore, we decided to manually create a new webapp project, which is reflected in the following aspects:
1. dependent on jdk 1.7
2. The Dynamic Web Module version is 3.0.
The procedure is as follows:
1. Check create a simple project (create a simple project and skip archetype selection)
2. Enter the maven project information normally and click Finish.
3. The generated project also reports an error. You need to modify the following: first, the pom. xml file, as shown in
<Build> <plugins> <! -- Configure jdk1.7 --> <plugin> <artifactId> maven-compiler-plugin </artifactId> <version> 3.3 </version> <configuration> <source> 1.7 </source> <target> 1.7 </target> </configuration> </plugin> </plugins> </build> <dependencies> <! -- Servlet-api --> <dependency> <groupId> javax. servlet </groupId> <artifactId> javax. servlet-api </artifactId> <version> 3.1.0 </version> </dependency> <! -- Jsp-api --> <dependency> <groupId> javax. servlet. jsp </groupId> <artifactId> jsp-api </artifactId> <version> 2.2 </version> </dependency> <! -- Jstl 1.2 --> <dependency> <groupId> javax. servlet </groupId> <artifactId> jstl </artifactId> <version> 1.2 </version> </dependency> <! -- Slf4j-log4j12 --> <dependency> <groupId> org. slf4j </groupId> <artifactId> slf4j-log4j12 </artifactId> <version> 1.7.7 </version> </dependency> </dependecies>
4. Then you need to manually create the WEB-INF directory and web. xml file, and update web. xml as follows:
<Web-app xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xmlns = "http://java.sun.com/xml/ns/javaee"
Xsi: schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
Version = "3.0"> </web-app>
5. Switch to the Navigator view and find the project facet configuration file under the. settings directory.org.eclipse.wst.common.project.facet.core.xml,
Change version to 3.0 and then update the project-<installed facet="jst.web" version="3.0"/>
6. Finally, update the maven project and update project (Alt + F5)