Eclipse Maven 开发一个 jee 项目时,编译时遇到以下错误:
Description Resource Path Location TypeDynamic Web Module 3.0 requires Java 1.6 or newer. bdp line 1 Maven Java EE Configuration ProblemDescription Resource Path Location TypeOne or more constraints have not been satisfied. bdp line 1 Maven Java EE Configuration Problem如图:- <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.6 以上:
-
- <build>
- <plugins>
- <!-- define the project compile level -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
- <configuration>
- <source>1.7</source>
- <target>1.7</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
dynamic web module 版本之间的区别:
Servlet 3.0 | JavaEE 6, JavaSE 6 | Pluggability, Ease of development, Async Servlet, Security, File Uploading | |
Servlet 2.5 | JavaEE 5, JavaSE 5 | Requires JavaSE 5, supports annotations | |
Servlet 2.4 | J2EE 1.4, J2SE 1.3 | web.xml |
错误Cannot change version of project facet Dynamic Web Module to 3.0:在项目右键属性的Project facts中把Dynamci Web Module设置为3.0,如果报错则直接修改项目文件:工程.settings目录下的org.eclipse.wst.common.project.facet.core.xml,同时把web.xml开头设置由2.5改成3.0为: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">然后执行项目右键Maven的Update Project...即可。