Eclipse uses Maven to create Dynamic Web Project and eclipsemaven
1. Click File-> New-> Other. In the displayed dialog box, select Maven-> Maven Project:
2. Click Next and select maven-archetype-webapp:
3. Fill in the Group ID and Artifact ID to automatically generate a package name:
4. Click Finish to generate the following directory:
5. right-click the root directory, select New-> Source Folder, and add three folders: src/main/java, src/test/java, and src/test/resources, if the prompt already exists, it indicates that it exists, but we cannot see it;
6. Modify the Build Path and select JRE as Workspace default JRE:
7. You can see that there are java folders under main, and then add several folders:
8. Select Output folder and sequence in Build Path:
9. Select Maven> Project Facets and change the Version of the Dynamic Web Module to 3.0. An error is reported. You need to modify the following files:
<?xml version="1.0" encoding="UTF-8"?><web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> </web-app>
Modify org. eclipse. jdt. core. prefs in the. settings folder of the project:
eclipse.preferences.version=1org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabledorg.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7org.eclipse.jdt.core.compiler.compliance=1.7org.eclipse.jdt.core.compiler.problem.assertIdentifier=errororg.eclipse.jdt.core.compiler.problem.enumIdentifier=errororg.eclipse.jdt.core.compiler.problem.forbiddenReference=warningorg.eclipse.jdt.core.compiler.source=1.7
Modify org. eclipse. wst. common. project. facet. core. xml:
<?xml version="1.0" encoding="UTF-8"?><faceted-project> <runtime name="Apache Tomcat v8.0"/> <fixed facet="wst.jsdt.web"/> <installed facet="java" version="1.7"/> <installed facet="jst.web" version="3.0"/> <installed facet="wst.jsdt.web" version="1.0"/></faceted-project>
Then, modify the Version of the Dynamic Web Module to 3.0. No error is reported this time:
After modification, the Red Cross on the project disappears:
10. add the project to the Server and run it again. The success is as follows: