混合不同版本的Java库

混合不同版本的Java库

问题描述:

我的项目使用具有自己的依赖关系的Java库(例如,Hadoop,Jetty)。我最终使用不同版本的相同依赖关系,如ant 1.4.5,1.4.6。我的项目可能要使用蚂蚁1.4.7。这是一个小例子,可以得到比较复杂的更大的依赖关系,如HTTP Commons。

My project uses Java libraries that have their own dependencies (Hadoop, Jetty for example). I end up with different versions of the same dependencies, like ant 1.4.5, 1.4.6. My project may want to use ant 1.4.7. This is a small example, can get more complicated with larger dependencies like HTTP Commons.

如何让所有的库和依赖项发挥好?有没有办法隔离每个库(Hadoop,Jetty),以便他们只使用它们的依赖关系?

How do I get all the libraries and dependencies to play nice? Is there a way to isolate each library (Hadoop, Jetty) so they only use their dependencies?

您可以选择管理所有这些都具有相关管理框架,如OSGI。看看Spring框架动态模块 http://www.springsource.org/osgi

You may choose to manage all of these with a depenency management framework - like OSGI. Take a look at the spring framework dynamic modules http://www.springsource.org/osgi

您还可以查看Eclipse实现OSGI的框架部分。看看这里 http://www.eclipse.org/osgi/

You can also take a look at the part of the framework where Eclipse implements OSGI. Take a look here http://www.eclipse.org/osgi/

简短的答案只是为了最低的共同点。记住,认可的目录是您的朋友 - 当涉及到管理冲突的依赖项时。

The short answer is just to go for the lowest common denominator. Remember that the 'endorsed' directory is your friend - when it comes to managing conflicting dependencies.