Creating a project with Maven and cannot change version Web module 3.0

Source: Internet
Author: User

Recently downloaded the latest Eclipse Mars.2, which comes with a Maven plugin, then uses MAVEN to try to create a Java Web project.

The first step, for example, is to choose Maven Project as you see it. Next

The second step. Note that create a simple project does not tick, Next

The third step is to enter the Web in the filter to retrieve the required archetypes at high speed, select then Next

Fourth step.

Group Id refers to the project group unique identifier, the structure of the actual corresponding Java package

Aftifact Id refers to a unique identifier for the item. is the project name

Finish, complete the creation of a project

Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity /center ">

The above is the process of completing a MAVEN project, but the newly created project may have some errors that need to be adjusted, and then continue to explain

First error:

The MAVEN project you just created has only the resource directory, and the Src/main/java and Src/test/java directories are missing (project right-click Properties). Visible in the Order and Export tab in Java Build path)

The workarounds are as follows:

Switch to the Libraries tab, check the JRE System library[j2 SE-1.5] and click Edit on the right side.

Do not use the default JDK, select the JDK in the alternate JRE to select the current environment (I use JDK 1.7), click Finish and OK to complete the setup

The missing directory already appears:

Next deal with the problem of JSP file compilation error

Select the project right-click property to return to the Java Build path form. Not much to say. Look at the picture


Here I was pre-configured TOMCAT7, click Finish, and then OK to the end, it is finished JSP compilation settings

A new MAVEN project is created. The newly created project, the JDK version number and the Web. XML version number is too low the JDK defaults to 1.5, and Web. XML defaults to 2.3.

Right-click Project--Properties--Project Facets

My JDK version number is 1.7 so Java select 1.7. The Dynamic Web Module selection 3.0,JDK will be set successfully, and the Dynamic Web module will find that it is not set.

Reported cannot change version of Project facet Dynamic Web module to 3.0 error

The workaround is to:

1. The contents of the file that changed Web. XML are:

<?xml version= "1.0" encoding= "UTF-8"?>
<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"
id= "webapp_id" version= "3.0" >

</web-app>

2. In the Navigator view, locate the. Setting directory under the project, open the file Org.eclipse.wst.common.project.facet.core.xml, and change the JDK from 1.5 to 1.7. Jst.web Change into 3.0

<?

XML version= "1.0" encoding= "UTF-8"?>
<faceted-project>
<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>

This is done, and it works, but there's a problem once again click Maven--Update Project. Just one night back to liberation.

So you need to add a configuration to the Pom.xml file so that you can guarantee Maven---Update Project. And then it was normal.

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>

Creating a project with Maven and cannot change version Web module 3.0

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.