首先先看一下错误信息:html
Dynamic Web Module 3.0 requires Java 1.6 or newer. Java compiler level does not match the version of the installed Java project facet. One or more constraints have not been satisfied.
错误信息图片:web
可是 Eclipse 明明已经将编译级别设置为 1.7:apache
这是因为你的 Maven 编译级别是 jdk1.5 或如下,而你导入了 jdk1.6 以上的依赖包:查看 Eclipse 的 Navigator 视图下该项目的 .classpath 文件:less
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"> <attributes> <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry>
解决办法:
使用 maven-compiler-plugin 将 maven 编译级别改成 jdk1.8 :eclipse
<build> <plugins> .... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> <encoding>UTF-8</encoding> </configuration> </plugin> .... </plugins> </build>
搞完以后记得刷新一下项目Update Project...maven
后记:ui
我当时错误缘由是由于马虎,把<plugin></plugin>标签写到了<plugins></plugins>的外面了。spa
而后pom.xml又没有报错。可是项目一直报这个错。debug
eclipse 建立maven 项目 动态web工程完整示例code