简体   繁体   English

Eclipse转到项目的Maven本地存储库副本,即使该项目存在于工作空间中

[英]Eclipse goes to maven local repo copy of a project, even though that project exists on the workspace

Using M2Eclipse plugin. 使用M2Eclipse插件。 Project A depends on Project B. Project B exists both in maven local repository and on workspace. 项目A取决于项目B。项目B同时存在于maven本地存储库和工作空间中。 While debugging, Eclipse ignores the workspace copy and goes to maven local repository copy of Project B. 调试时,Eclipse将忽略工作空间副本,并转到Project B的Maven本地存储库副本。

But the weird thing is, when I remove Project B from the pom.xml of Project A, Eclipse goes to workspace copy. 但是奇怪的是,当我从项目A的pom.xml中删除项目B时,Eclipse进入了工作区副本。

I have tried: 我努力了:

  • Disabling workspace resolution of Project A and re-enabling it. 禁用项目A的工作空间分辨率,然后重新启用它。
  • Clean installing Project A and Project B. 干净安装Project A和ProjectB。
  • Force updating Project A. 强制更新项目A。

Neither of these worked. 这些都不起作用。 When I remove Project B from pom.xml of Project A, it works. 当我从项目A的pom.xml中删除项目B时,它可以工作。 When I re-add Project B to the pom.xml of Project A, Eclipse goes to maven local repo copy of Project B again. 当我将项目B重新添加到项目A的pom.xml中时,Eclipse再次转到项目B的Maven本地存储库副本中。 But removing Project B from the list of dependencies of Project A is obviously not the way to go. 但是从项目A的依赖项列表中删除项目B显然不是可行的方法。

Did anyone else observed this weird behavior? 有没有其他人观察到这种奇怪的行为? What should I do to stop this happening? 我应该怎么做才能阻止这种情况的发生?

Within Eclipse, you can add, in the dependent project (Project A), a link to your workspace project (Project B), instead of the one inside your Maven local repo. 在Eclipse中,您可以在从属项目(项目A)中添加到工作区项目 (项目B)的链接,而不是Maven本地存储库中的链接。

You have to do this on the dependent project (project A): Right click > Build path > Configure Build path... and in the Projects tab, you add your workspace project . 您必须在相关项目(项目A)上执行此操作: Right click > Build path > Configure Build path...然后在“ Projects选项卡中添加工作区项目

I found it. 我找到了。 Apparently, someone has changed the version of Project B dependency on Project A's pom.xml from TEST-SNAPSHOT to UAT-SNAPSHOT . 显然,有人更改了对项目A的pom.xml的项目B依赖项的版本,从TEST-SNAPSHOT更改为UAT-SNAPSHOT Since the version of Project B on my workspace is TEST-SNAPSHOT , Eclipse naturally thinks that this is not the version it is looking for, and hence, it goes to maven local repository. 由于我的工作区上的Project B版本是TEST-SNAPSHOT ,因此Eclipse自然认为这不是它正在寻找的版本,因此,它进入了Maven本地存储库。

In other words, Project A's pom.xml changed from this: 换句话说,项目A的pom.xml与此更改:

... 
<dependency>
            <groupId>SomeGroupID</groupId>
            <artifactId>Project_B</artifactId>
            <version>TEST-SNAPSHOT</version>
</dependency>
...

to this: 对此:

... 
<dependency>
            <groupId>SomeGroupID</groupId>
            <artifactId>Project_B</artifactId>
            <version>UAT-SNAPSHOT</version>
</dependency>
...

And this is the pom.xml of the Project B in my workspace: 这是我的工作区中Project B的pom.xml

...
<groupId>SomeGroupID</groupId>
<artifactId>Project_B</artifactId>
<version>TEST-SNAPSHOT</version>
...

Since Project A references UAT-SNAPSHOT version of Project B (instead of TEST-SNAPHOT version), Eclipse naturally thinks that Project B in my workspace is not the project which Project A is looking for. 由于Project A引用了Project B的UAT-SNAPSHOT版本(而不是TEST-SNAPHOT版本),因此Eclipse自然认为我的工作区中的Project B不是Project A正在寻找的项目。 Hence, Eclipse goes to my local maven repository. 因此,Eclipse进入了我的本地Maven存储库。

Take home message is, one should check very carefully that the version being referenced, and the version of the project which you expect to be referenced matches exactly. 带回家的消息是,应该非常仔细地检查所引用的版本与您希望被引用的项目的版本是否完全匹配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM