Dynamic Web Module 選擇“3.1”,java選擇“1.8”,報錯:Cannot change version of project facet Dynamic web module to 3.1,如下圖:


解決方法:
1、把servlet修改成3.1,打開maven項目的web.xml, 修改為:


2、修改.settings文件夾下的org.eclipse.wst.common.project.facet.core.xml 為:
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<installed facet="java" version="1.8"/>
<installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="jst.web" version="3.1"/>
</faceted-project>
3、pom.xml中添加:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
4、Project Facets 重新配置:Dynamic Web Module選擇“3.1”,java選擇“1.8”

