Maven困惑了JRE被使用过 [英] Maven confused about JRE been used

查看:159
本文介绍了Maven困惑了JRE被使用过的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在eclipse中创建了一个项目,并添加了maven依赖关系。在Eclipse中,它表示我正在使用JRE 1.5。一切都可以在Eclipse中运行,例如,我可以运行我的测试。



当我尝试从终端运行 mvn clean install 时,会给我以下错误。 >


... -source 1.3中不支持泛型(使用-source 5或更高版本启用泛型)...


似乎Maven认为我使用JRE 1.3,无法识别泛型或for-each循环。



我如何:




  • 验证我假设maven使用错误版本。

  • 让Maven编译我的项目。


解决方案

在Maven编译器插件中指定正确的JRE版本,默认情况下, code> pom.xml 文件将从Maven超级 pom.xml 继承编译器插件,该目标是1.3 JRE。 p>

 < build> 
< plugins>
< plugin>
< artifactId> maven-compiler-plugin< / artifactId>
< configuration>
< source> 1.5< / source>
< target> 1.5< / target>
< / configuration>
< / plugin>
< / plugins>
< / build>


I've created a project in eclipse and added maven dependencies. In Eclipse, it says that I am using JRE 1.5. Everything works fine in Eclipse, for instance, I can run my tests.

When I try to run mvn clean install from the terminal, it gives me the following error.

...generics are not supported in -source 1.3 (use -source 5 or higher to enable generics)...

Its seems that Maven thinks I'm using JRE 1.3 and cannot recognize generics or for-each loops.

How can I:

  • Validate my assumption that maven is using the wrong version.
  • Get Maven to compile my project.

解决方案

Specify the correct version of your JRE in the Maven compiler plugin, by default your pom.xml file will inherit the compiler-plugin from the Maven super pom.xml which targets the 1.3 JRE.

     <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>    
        </plugins>
    </build>

这篇关于Maven困惑了JRE被使用过的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆