更新Maven不断从Java JDK 1.8恢复到Eclipse中的JavaSE -1.8 [英] Update Maven Keeps Reverting Back to JavaSE -1.8 in Eclipse from Java JDK 1.8

查看:391
本文介绍了更新Maven不断从Java JDK 1.8恢复到Eclipse中的JavaSE -1.8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何阻止maven将Java系统库从JDK 1.8不断更新回Java SE 1.8?我已经配置了构建路径,甚至将Java_Home变量设置为JDK路径.我还更新了构建配置.我是新手吗,有人可以通过一些具体说明指定如何执行此操作.我还注意到,这种情况也不断发生变化.仅供参考,如果这很重要,我正在使用Eclipse Mars.

How do I stop maven from constantly updating my Java System Library from JDK 1.8 back to Java SE 1.8? I have configured the build path and I even set my Java_Home Variable to the JDK path. I have also have updated the build configuration. Can someone please specify how to do this with some specific instructions as I am a novice. I also noticed this keeps changing back as well. FYI I am using Eclipse Mars if that matters.

关于以下评论,我共享了Eclipse M2e插件屏幕截图.即使被选中,我也无法继续下一步.我还展示了已经安装的东西,以防万一另一个插件妨碍我使用m2e

In Regards to the comments below I have shared the Eclipse M2e Plugin screenshot. Even when selected I am not able to proceed to next. I also have shown what's already installed just in case another plugin is hindering me from using the m2e

推荐答案

您需要了解什么是执行环境(EE )是在Eclipse中. EE的概念是对JRE的抽象,允许在配置项目时没有指向JRE位置的绝对路径.在Wiki页面上:

You need to understand what an Execution Environment (EE) is in Eclipse. The concept of EE is an abstraction over JREs, allowing projects to be configured without absolute paths to JRE locations. From the wiki page:

执行环境(EE)是JRE的符号表示.例如,您可以谈论J2SE-1.4执行环境,而不是谈论在磁盘上特定位置使用特定名称的特定JRE.然后可以将系统配置为使用特定的JRE来实现该执行环境.

Execution environments (EEs) are symbolic representations of JREs. For example, rather than talking about a specific JRE, with a specific name at a specific location on your disk, you can talk about the J2SE-1.4 execution environment. The system can then be configured to use a specific JRE to implement that execution environment.

通常,建议不要将项目配置为使用默认工作区"作为其JRE系统库,因为这会使项目在加载到不同的工作区时不一致.考虑一下:如果该项目是针对Java 7开发的,但是我将其放入具有JDK 8的工作区中,该怎么办?那可能是个大问题.通过使用EE,可以对项目进行配置,以使其不知道(或不关心)我的系统上实际有匹配的JRE的位置.

In general, it's not advisable to configure a project to use "Workspace default" as its JRE System Library, because that makes the project inconsistent when loaded into different workspaces. Think about this: what if the project is being developed targeting Java 7, but I pull it into my workspace which has JDK 8; that could be a big problem. By using an EE, the project is configured such that it doesn't know (or care) where I actually have a matching JRE on my system.

我说了所有这些都是为了为您设置答案,因此您了解了Maven在做什么以及这些说明正在做什么. m2e是Eclipse的Maven集成插件,正在(正确地)将项目配置设置为使用EE而不是默认工作区".从屏幕截图中,我可以看到您在工作空间中同时设置了JDK和JRE 1.8,因此理想情况下,您应该删除其中一个(即JRE).转到首选项> Java > 已安装的JRE .在那里,您将看到列出的JRE和JDK.我建议删除JRE *.

I said all that to set up the answer for you, so you understand what Maven is doing and these instructions are doing. m2e, the Maven integration plugin for Eclipse, is (rightly) setting the project configuration to use an EE instead of "workspace default". From your screen shot I can see that you have both JDK and JRE 1.8 set up in your workspace, so ideally you should remove one (the JRE). Got to Preferences > Java > Installed JREs. There you'll see both the JRE and JDK listed. I suggest removing the JRE*.

然后进入执行环境"首选项部分,选择 JavaSE-1.8 并确保已将JDK选中为默认实现.

Then go into the "Execution Environments" preferences section, select JavaSE-1.8 and make sure that your JDK is checked as the default implementation.

现在,当m2e将您的项目配置为使用EE时,该EE将指向您已安装的JDK.而且,如果其他人导入了该项目,它将指向他们安装了匹配的JDK的任何地方.

Now when m2e configures your projects to use an EE, that EE will be pointing to the JDK you have installed. And if someone else imports the project, it will point to wherever they have a matching JDK installed.

*顺便说一句,在那里有不同版本的Java是完全可以接受和正常的;我经常从事针对不同Java版本的不同项目.

*By the way, it's perfectly acceptable and normal to have different versions of Java there; I often work on different projects that target different Java versions.

这篇关于更新Maven不断从Java JDK 1.8恢复到Eclipse中的JavaSE -1.8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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