问题描述
我已经在eclipse中创建了一个项目,并添加了maven依赖关系。在Eclipse中,它表示我正在使用JRE 1.5。一切都可以在Eclipse中运行,例如,我可以运行我的测试。当我尝试从终端运行 mvn clean install
时,会给我以下错误。 >
似乎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.
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被使用过的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!