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

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

但是 Eclipse 明明已经将编译级别设置为 1.7:
Eclipse compiler
这是由于你的 Maven 编译级别是 jdk1.5 或以下,而你导入了 jdk1.6 以上的依赖包:查看项目目录下的 .classpath 文件:

<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标签内

<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

转载于:https://www.cnblogs.com/xinhudong/p/6632128.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值