The web project built by maven, webversion defaults to 2.3, jdk defaults to 1.5

1. Web Version modification

First see the following interface (if there is no such view, Window->Show View->Navigator)


Open the file I selected org.eclipse.wst.common.project.facet.core.xml

The original content is as follows:

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

Modify this property of jst.web as follows:

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

This will change the Web version from the default 2.3 to 3.0

2. JDK Version modification

Open the pom.xml file and find the <build> tag

Add the following tags:

<plugins>
	<plugin>
		<groupId>org.apache.maven.plugins</groupId>
		<artifactId>maven-compiler-plugin</artifactId>
		<version>3.0</version>
		<configuration>
			<source>1.8</source>
			<target>1.8</target>
		</configuration>
	</plugin>
</plugins>

Third, update the Maven project

Right-click on the project - "Maven-"Update Project

Finish.

The solution to the problem is just documented here, but I don't know the reason


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325734422&siteId=291194637