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.
我在eclipse中创建了一个项目,并添加了maven依赖项。在Eclipse中,它说我使用的是JRE 1.5。在Eclipse中,一切都运行良好,例如,我可以运行我的测试。
When I try to run mvn clean install
from the terminal, it gives me the following error.
当我尝试从终端运行mvn clean安装时,它给了我以下错误。
...generics are not supported in -source 1.3 (use -source 5 or higher to enable generics)...
…在-source 1.3中不支持泛型(使用-source 5或更高版本以启用泛型)…
Its seems that Maven thinks I'm using JRE 1.3 and cannot recognize generics or for-each loops.
似乎Maven认为我在使用JRE 1.3,不能识别泛型或for-each循环。
How can I:
我怎么能:
- Validate my assumption that maven is using the wrong version.
- 验证我的假设,即maven使用了错误的版本。
- Get Maven to compile my project.
- 让Maven编译我的项目。
2 个解决方案
#1
27
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.
默认情况下,在Maven编译器插件中指定JRE的正确版本。xml文件将从Maven超级pom继承编译器插件。以1.3 JRE为目标的xml。
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
#2
-3
Make sure you have the correct JAVA_HOME. Then go check the project facet in eclipse to make sure the Java version is reflecting the right version.
确保您拥有正确的JAVA_HOME。然后检查eclipse中的项目方面,确保Java版本反映了正确的版本。
#1
27
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.
默认情况下,在Maven编译器插件中指定JRE的正确版本。xml文件将从Maven超级pom继承编译器插件。以1.3 JRE为目标的xml。
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
#2
-3
Make sure you have the correct JAVA_HOME. Then go check the project facet in eclipse to make sure the Java version is reflecting the right version.
确保您拥有正确的JAVA_HOME。然后检查eclipse中的项目方面,确保Java版本反映了正确的版本。