在Eclipse m2e中,如何参考工作区项目? [英] In Eclipse m2e, how to reference workspace project?

查看:123
本文介绍了在Eclipse m2e中,如何参考工作区项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Eclipse m2e 引用另一个工作区项目?



我必须在项目设置中添加项目依赖关系吗?但是在这种情况下,依赖关系不会显示在pom中。



如果我将它们设置为pom,它不会在工作空间中引用该项目,而是在本地存储库。相当讨厌,有人可以帮忙吗?

解决方案

正确的方法如下:




  • 专门使用POM文件中的依赖关系部分,不要拖曳Eclipse项目引用。右键单击项目,然后选择Maven>更新项目配置将项目重置为Maven默认设置。这样, m2e 具有依赖关系的所有权。

  • 确保所有引用的项目都在Eclipse中打开,并启用Maven

  • 检查每个项目的Maven设置,确保 groupId artifactId 版本匹配与您在Eclipse中打开的项目。因此,如果您依赖的项目在Eclipse中具有版本 1.0.0-SNAPSHOT ,请确保依赖项目的POM文件在中引用 1.0.0-SNAPSHOT >依赖关系部分。

  • 为每个项目启用工作区分辨率。右键单击该项目,然后单击Maven>启用工作区分辨率。

  • 最后,如果项目仍未解决,请再次右键单击项目, em> Maven>更新项目



这应该可以解决你的问题。如果之后,您的依赖关系仍然从文件系统引用,请再次检查每个依赖关系的 groupId artifactId ,特别是版本。 p>

还要检查你的项目是否没有任何错误 - 尝试运行Maven安装。


How can I reference another workspace project using Eclipse m2e?

Do I have to add a project dependency in the project setting? But in that case the dependency is not shown in the pom.

If I set them in the pom, it will not reference the project in workspace but reference the jar in the local repository. Quite annoying, anyone can help?

解决方案

The correct way to do this is the following:

  • Use the dependencies section in the POM file exclusively, don't fiddle with the Eclipse project references. Right-click the project, then select Maven > Update Project Configuration to reset the project to the Maven default settings. This way, m2e has ownership of the dependencies.
  • Make sure all referenced projects are open in Eclipse and have the Maven nature enabled.
  • Check the Maven settings for each project, make sure that groupId, artifactId and version match with the projects you have open in Eclipse. So if the project you depend on has version 1.0.0-SNAPSHOT in Eclipse, make sure that the depending project's POM file references version 1.0.0-SNAPSHOT in the dependencies section.
  • Enable Workspace Resolution for each of the projects. Right-click the project, then Maven > Enable Workspace Resolution.
  • Finally, if the projects are still not resolved, right-click the project again, then Maven > Update Project

This should solve your problem. If after this, your dependencies are still referenced from the file system, check the groupId, artifactId and especially version of each dependency again.

Also check if you don't have any errors in your project - try to run Maven install.

这篇关于在Eclipse m2e中,如何参考工作区项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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