Type Cannot change version of project facet Dynamic Web Module to 3.1.

the reason:

The defaults in the new dynamic web project web.xml are as follows:

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

The version 2.3 here is too old, so it is modified to a newer version, such as version 3.1

After modification as follows

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                      http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
	version="3.1" metadata-complete="true">
  <display-name>Archetype Created Web Application</display-name>
</web-app>

At this time, the following error appears

The reason is that the level of maven compiling jdk is too low,

Right-click the project --> properties --> project facets --> Dynamic Web MOdule change 2.3 to 3.1

But found that it cannot be modified here

Find the org.eclipse.wst.common.project.facet.core.xml file in the project folder.settings directory

Modify the content as follows, java 1.8, jst.web 3.1

<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
  <fixed facet="wst.jsdt.web"/>
  <installed facet="java" version="1.8"/>
  <installed facet="jst.web" version="3.1"/>
  <installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project>

Open the pom.xml file and add the maven plug-in

  <build>
    <finalName>study</finalName>
   	<plugins>
		<plugin>
			<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-compiler-plugin</artifactId>
			<version>3.8.1</version>
			<configuration>
				<source>1.8</source>
				<target>1.8</target>
				<encoding>UTF8</encoding>
			</configuration>
		</plugin>
	</plugins>
  </build>

Save and exit

Right click on the project --> maven --> upload project

Guess you like

Origin blog.csdn.net/qq_26896085/article/details/108167307