m2eclipse 对类路径的多个依赖项
它可能是重复的,但是在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,这不是真的。 Maven 将您告诉他的内容放在类路径上。
使用 Eclipse,当您打开类型时,Eclipse 只需在工作区中所有项目的类路径中搜索类型即可。因此,如果您的项目 A 的类路径上有
foo-X.jar
,项目 B 的类路径上有foo-Y.jar
并且两者都包含Bar
类型,搜索Bar
将列出两个版本。但是 Eclipse 不会在工作空间中未定义为项目依赖项的 JAR 中进行搜索,也不会在本地存储库的所有 JAR 中进行搜索。这并不是 Maven 或 m2eclipse 特有的问题。
也就是说,我知道将搜索限制为仅项目 A 的依赖项的唯一方法是使用右上角的菜单定义一个工作集箭头:
No, that's not true. Maven puts on the class path what you tell him to put on it.
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 hasfoo-Y.jar
on its classpath and if both contain theBar
type, searching forBar
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: