Eclipse Maven 开发一个 jee 项目时,编译时遇到以下错误
Description Resource Path Location Type
Dynamic Web Module 3.0 requires Java 1.6 or newer. bdp line 1 Maven Java EE Configuration Problem

Description Resource Path Location Type
One or more constraints have not been satisfied. bdp line 1 Maven Java EE Configuration Problem
如图:
Eclipse Maven 编译错误 Dynamic Web Module 3.0 requires Java 1.6 or newer 解决方案
但是 Eclipse 明明已经将编译级别设置为 1.7:
Eclipse Maven 编译错误 Dynamic Web Module 3.0 requires Java 1.6 or newer 解决方案
这是由于你的 Maven 编译级别是 jdk1.5 或以下,而你导入了 jdk1.6 以上的依赖包:查看 Eclipse 的 Navigator 视图下该项目的 .classpath 文件:

 
  1. <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">

  2. <attributes>

  3. <attribute name="maven.pomderived" value="true"/>

  4. </attributes>

  5. </classpathentry>


解决办法
使用 maven-compiler-plugin 将 maven 编译级别改为 jdk1.6 以上:

 
  1. <build>

  2. <plugins>

  3. <!-- define the project compile level -->

  4. <plugin>

  5. <groupId>org.apache.maven.plugins</groupId>

  6. <artifactId>maven-compiler-plugin</artifactId>

  7. <version>2.3.2</version>

  8. <configuration>

  9. <source>1.7</source>

  10. <target>1.7</target>

  11. </configuration>

  12. </plugin>

  13. </plugins>

  14. </build>

相关文章:

  • 2021-11-20
  • 2022-12-23
  • 2021-07-07
  • 2021-09-22
  • 2021-10-29
猜你喜欢
  • 2021-07-10
相关资源
相似解决方案