开发者

m2eclipse multiple dependencies on classpath

开发者 https://www.devze.com 2023-01-21 11:41 出处:网络
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 ?

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 e开发者_Python百科tc.), 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.


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:

m2eclipse multiple dependencies on classpath

0

精彩评论

暂无评论...
验证码 换一张
取 消