Eclipse creates maven-web project and resolves JRE version and Web. XML version issues

Source: Internet
Author: User

When Eclipse builds the SSM Framework project (Web project) through Maven, the default web.xml file version is 2.3,JRE version 1.5, and there are various issues in modifying its version
For example:

web.xml  Is missing and <failOnMissingWebXml> is set to truejavaserver Faces 2.2 can not is Installed:one or more constraints There are not been satisfied. JavaServer Faces 2.2 requires dynamic Web module 2.5 or newer issues    

When you look up a method, the configuration order error is also the cause of the problem. To modify the JRE and Web. xml version, to handle the relationship between the versions, such as web3.0 need more than Java 1.6, JavaServer Faces need web version 2.5 and so on, understand the rules, can be a good solution to the problem.
Here is a summary of a method that has the entire process created.

In addition: One possible way is to modify .settings/org.eclipse.wst.common.project.facet.core.xml the Web and Java versions of files in the project directory. The following method does not need to modify this file, it is more convenient.

Eclipse version:Neon.1a Release (4.6.1)

1. Create a new Maven Project

ChooseMaven Project

Choosemaven-archetype-webapp

Group IdIs the unique identifier of the project organization, which actually corresponds to the structure of the Java package, is the directory structure of Java in the main directory.
Artifact IdIs the unique identifier of the project, the name of the actual project, which is the name of the project root directory.

The new MAVEN project structure is:

Note the structure of the red box, there is only one src/main/resources, and the project report below the HttpServlet error

Project Right click Properties Select Java Build Path Select Add Library Add Server Runtime Select Apache Tomcat7 Server (TOMCAT8 requires Web version 3.1)

HttpServlet error resolution, project structure changes, auto-completion src/main/java and src/test/java catalog

The Web. Xml version of the MAVEN project is now 2.3,JRE version 1.5 and needs to be upgraded.

2. Modify the project JRE version and Web. XML version

Online version of the many and miscellaneous, their own practice is the key

2.1 Modifying the JRE version

Changes to the JRE version can no longer be Java Bulid Path modified, and once the project update project returns to the 1.5 version, it is declared in the Pom.xml file.

pom.xml

...<Build><Finalname>testmaven3</Finalname><Plugins><!--modify MAVEN's default JRE-compiled version, 1.8 for JRE-compiled version, choose 1.7 or 1.8 depending on your installation version<Plugin><Groupid>org.apache.maven.plugins</Groupid><artifactid>maven-compiler-plugin </artifactid> <configuration > <source>1.8</source> <target>1.8 </target> </configuration> </plugin> </ plugins> </build></PROJECT>         

Project Right-click to select Maven Update Project project Java Build Path for:

You can then Edit the JRE to specify theWorkspace default JRE

2.2 Modifications web.xmlFile version

This is generated by default web.xml and can be seen in version 2.3.

web.xml

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" ><web-app>  <display-name>Archetype Created Web Application</display-name></web-app>

Project right-click to Properties Select Project Facets (project template), as you can see Dynamic Web Module version 2.3

Change directly to 3.0? , but it cannot be changed

You can Dynamic Web Module remove the tick first, then apply.

Then tick Dynamic Web Module , note the options below, Further configuration available... then change to the desired version 3.0, clickFurther configuration available...

After that, change Content director to src/main/webapp , tick Generate web.xml deployment descriptor OK, save exitProject Facets

After modifying the src/main/webapp/WEB-INF/web.xml file, the header information version is modified to version 3.0.

web.xml

<?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>

After that, project right-click to select Maven Update Project .

The project structure is:

Eclipse creates maven-web project and resolves JRE version and Web. XML version issues

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.