java被更新怎么恢复,更新Maven不断从Java JDK 1.8恢复到Eclipse中的JavaSE -1.8

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.

QyPgF.png

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

jp2ao.png

解决方案

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:

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.

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.

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*.

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

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.

*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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值