m2eclipse 对类路径的多个依赖项

发布于 2024-09-28 18:00:14 字数 297 浏览 4 评论 0原文

它可能是重复的,但是在 Eclipse 中,我如何处理本地 Maven 存储库中同一库的各种依赖版本?

问题是pom定义中指定的依赖版本是我需要使用的库(它们有可用的sources/javadoc等),但是maven将所有可用的库版本放在类路径上,这样如果我ctrl+shift+T或step进入属于该依赖项的某个类,它可能是没有sources/javadoc的类,该类没有在pom定义中声明,而是在本地maven存储库中声明。没有办法设置优先级。

弹出窗口中(Ctrl+Shift+T)有一个“从历史记录中删除”功能,但它实际上没有用,不起作用。

it might be a duplication, but in eclipse, how can I deal with various dependency versions of the same library in my local maven repository ?

The problem is that dependency versions specified in pom definition are the libraries I need to use (they have sources/javadoc available etc.), but maven puts all the available library versions on classpath, so that if I ctrl+shift+T or step into some class which belongs to that dependency, it might be the one without sources/javadoc, the one not declared in pom definition but in local maven repo. There is no way of setting up precedence.

There is a feature "Remove from history" right in the pup up window (Ctrl+shift+T), but it is practically useless, doesn't work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

-残月青衣踏尘吟 2024-10-05 18:00:14

问题是pom定义中指定的依赖版本是我需要使用的库(它们有可用的sources/javadoc等),但是maven将所有可用的库版本放在类路径上(...)

不,这不是真的。 Maven 将您告诉他的内容放在类路径上。

(...) 这样,如果我 ctrl+shift+T 或进入某个属于该依赖项的类,它可能是没有 resources/javadoc 的类,该类未在 pom 定义中声明,而是在本地 Maven 存储库中声明.

使用 Eclipse,当您打开类型时,Eclipse 只需在工作区中所有项目的类路径中搜索类型即可。因此,如果您的项目 A 的类路径上有 foo-X.jar ,项目 B 的类路径上有 foo-Y.jar 并且两者都包含Bar 类型,搜索 Bar 将列出两个版本。

但是 Eclipse 不会在工作空间中未定义为项目依赖项的 JAR 中进行搜索,也不会在本地存储库的所有 JAR 中进行搜索。这并不是 Maven 或 m2eclipse 特有的问题。

也就是说,我知道将搜索限制为仅项目 A 的依赖项的唯一方法是使用右上角的菜单定义一个工作集箭头:

替代文本

The problem is that dependency versions specified in pom definition are the libraries I need to use (they have sources/javadoc available etc.), but maven puts all the available library versions on classpath (...)

No, that's not true. Maven puts on the class path what you tell him to put on it.

(...) so that if I ctrl+shift+T or step into some class which belongs to that dependency, it might be the one without sources/javadoc, the one not declared in pom definition but in local maven repo.

With Eclipse, when you Open Type, Eclipse simply searches for the type in the classpath of all projects in the workspace. So if you have a project A that has foo-X.jar on its classpath and a project B that has foo-Y.jar on its classpath and if both contain the Bar type, searching for Bar would list both versions.

But Eclipse doesn't search in JARS that are not defined as dependencies of projects in your worskpace, it doesn't search in all JARs of your local repository. And this is not really a Maven or m2eclipse specific issue.

That said, the only way I know to restrict the search to, say the dependencies of project A only, would be to define a Working Set using the menu under the upper right arrow:

alt text

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文