m2eclipse 将 JDK 合规性设置为 1.4
使用eclipse 3.5,当我创建一个新的maven项目时,m2eclipse自动将J2SE1.4添加到库中,并将编译器合规级别添加到1.4(项目属性> Java编译器)。 我的 JRE 系统库是 1.6,我的默认编译器合规级别是 1.6。我什至没有安装1.4。 我可以让 m2eclipse 使用我的默认设置并阻止它修改项目设置吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它应该遵循
maven-compiler-plugin
配置:(即使,如 在此线程中提到,它不适用于方面-j)
这个线程提醒我们 Eclipse 中的 m2eclipse 和 Maven 脚本之间的区别:
所以:
It should follow the
maven-compiler-plugin
configuration:(even if, as mentioned in this thread, it won't work for aspect-j)
This thread reminds us about the difference between m2eclipse within eclipse, and a maven script:
So:
JDK 合规性级别是从 Maven 项目派生的,而不是相反。换句话说,您需要配置maven编译器插件以符合1.6级别,然后m2eclipse将在Eclipse下导出适当的设置:
pom.xml
是master,而不是m2eclipse。The JDK compliance level is derived from the maven project, not the other way around. In other words, you need to configure the maven compiler plugin for 1.6 level compliance and then m2eclipse will derive the appropriate settings under Eclipse:
The
pom.xml
is the master, not m2eclipse.总之,我对项目执行了
mvn eclipse:eclipse
,并在 Eclipse 中对项目进行了 F5 刷新,这正确配置了 Java 合规性设置。我的设置如下。使用开普勒。 Java 1.7 在 Eclipse 的首选项中配置为默认值(正如已经提到的,似乎无论如何都会被忽略,以尊重 pom.xml 中找到的任何内容)。我将一堆 Maven 项目导入到 Eclipse 中。所有这些都显示为 Java 合规级别 1.4,甚至项目的构建路径也列出了 Java 1.4 运行时。我通过在命令行上请求有效的 pom 来仔细检查 1.7 是否在 pom.xml 中正确指定,以确认 pom 中存在且正确的设置:
这表明存在正确的设置:
猜测问题出在导入部分m2e插件,Eclipse中显示的版本是:
1.4.0.20130601-0317
In summary I did an
mvn eclipse:eclipse
on the project and an F5 refresh of the project in Eclipse and this configured the Java compliance setting correctly.My set-up as follows. Using Kepler. Java 1.7 configured as default in preferences in Eclipse (as mentioned already, seems to be ignored anyway in deference to whatever is found in the pom.xml). I imported a bunch of Maven projects into Eclipse. All showed up as Java compliance level 1.4 and even the build path of the projects lists the Java 1.4 runtime. I double checked 1.7 is correctly specified in the pom.xml by requesting the effective pom on the command line to confirm the setting is present and correct in the pom:
This showed the correct setting was present:
Guessing the problem is with the import part of the m2e plugin, version showing in Eclipse is:
1.4.0.20130601-0317