是什么原因导致Eclipse中的导入Maven项目默认使用Java 1.5而不是Java 1.6,我怎样才能确保它不会? [英] What causes imported Maven project in Eclipse to use Java 1.5 instead of Java 1.6 by default and how can I ensure it doesn't?

查看:210
本文介绍了是什么原因导致Eclipse中的导入Maven项目默认使用Java 1.5而不是Java 1.6,我怎样才能确保它不会?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我导入了一个Maven项目并且它使用了Java 1.5,尽管我已经将1.6配置为我的Eclipse默认 Preferences-> Java-> Installed JREs

I imported a Maven project and it used Java 1.5 even though I have 1.6 configured as my Eclipse default Preferences->Java->Installed JREs.

当我改变Maven项目以使用1.6 JRE时,它仍然存在从项目使用Java 1.5时遗留的构建错误(我在前面描述了这些构建错误) :我在m2eclipse上构建错误但在命令行没有使用maven2 - 我的m2eclipse是否配置错误?

When I changed the Maven project to use the 1.6 JRE it still had the build errors left over from when the project was using Java 1.5 (I described these build errors earlier in: I have build errors with m2eclipse but not with maven2 on the command line - is my m2eclipse misconfigured?)

我要删除项目和再试一次,但我想确保这次它从一开始就使用Java 1.6来看看是否能消除构建问题。

I'm going to delete the project and try again but I want to make sure this time that it uses Java 1.6 from the start to see if this eliminates the build problems.

如何确保项目使用我导入Java 1.6时?

How do I make sure the project uses Java 1.6 when I import it?

推荐答案

m2eclipse插件不使用Eclipse默认值,m2eclipse插件从中导出设置POM。因此,如果您希望在Eclipse下导入时将Maven项目配置为使用Java 1.6设置,请按照我的建议正确配置 maven-compiler-plugin

The m2eclipse plugin doesn't use Eclipse defaults, the m2eclipse plugin derives the settings from the POM. So if you want a Maven project to be configured to use Java 1.6 settings when imported under Eclipse, configure the maven-compiler-plugin appropriately, as I already suggested:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>2.1</version>
  <configuration>
    <source>1.6</source>
    <target>1.6</target>
  </configuration>
</plugin>

如果您的项目已导入,请更新项目配置(右键单击在项目上 Maven V更新项目配置)。

If your project is already imported, update the project configuration (right-click on the project then Maven V Update Project Configuration).

这篇关于是什么原因导致Eclipse中的导入Maven项目默认使用Java 1.5而不是Java 1.6,我怎样才能确保它不会?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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