前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Maven 编译错误 Dynamic Web Module 3.0 requires Java 1.6 or newer 解决方案

Maven 编译错误 Dynamic Web Module 3.0 requires Java 1.6 or newer 解决方案

作者头像
I Teach You 我教你
发布2018-01-02 18:15:34
1.4K0
发布2018-01-02 18:15:34
举报

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 如图:

Dynamic Web Module 3.0 requires Java 1.6 or newer
Dynamic Web Module 3.0 requires Java 1.6 or newer

但是 Eclipse 明明已经将编译级别设置为 1.7:

Eclipse compiler
Eclipse compiler

这是由于你的 Maven 编译级别是 jdk1.5 或以下,而你导入了 jdk1.6 以上的依赖包:查看项目目录下的 .classpath 文件:

代码语言:javascript
复制
<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 以上:(注意以下plugins一定要放在Pom.xml文件里的build标签内)

代码语言:javascript
复制
<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>  

参考资料

  1、http://stackoverflow.com/questions/12857535/eclipse-maven-update-causes-corruption-of-jvm-setting

      2、http://stackoverflow.com/questions/5783338/what-is-the-use-of-org-eclipse-jdt-launching-jre-container-in-eclipse

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2017-03-28 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档