Issues with Clojure inter-dependency with different major versions of the same library

人走茶凉 提交于 2019-12-07 23:06:01

问题


Disclojure: I am not a Java developer and I have little knowledge in Maven.

I am facing a problem with Clojure/Lein. I am developing a project that uses two external libraries/projects that are un-related. Both of the uses the Sesame RDF library. One of them is Any23 which uses Sesame 2.x but the other uses the version 4.x. The problem is that Any23 won't work with Sesame 4.x and the other library won't work with Sesame 2.x.

This means that :exclusions one or the other in my project.clj file won't work.

Do any solution exists to fix such dependencies issues or am I stuck?


回答1:


There aren't any easy answers for this problem. Here are some options:

  • Upgrade Any23 to use Sesame 4.x
  • Use something like Maven Shade to rename one of the Sesame packages so that they can both be loaded on the same classpath. You may run into trouble if you try to use or share objects between the two libraries.
  • Use Clojure OSGI to isolate the packages. (This is probably the most difficult option, although also the most 'correct').

For more info, see Java, Classpath, Classloading => Multiple Versions of the same jar/project and Wikipedia's entry on JAR Hell.



来源:https://stackoverflow.com/questions/35328825/issues-with-clojure-inter-dependency-with-different-major-versions-of-the-same-l

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!