Eclipse uses Maven to create Dynamic Web Project and eclipsemaven

Source: Internet
Author: User
Tags apache tomcat

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:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.