如何在Clojure中修复此依赖性问题?

时间:2015-05-22 19:28:01

标签: clojure jackson dependencies leiningen amazonica

我在解决两个不同软件包的依赖项发生冲突的问题时遇到了很多麻烦。我的project.clj的依赖项看起来像这样:

  :dependencies [[org.clojure/clojure "1.6.0"]
                 [itsy "0.1.1"]  
                 [amazonica "0.3.22" :exclusions [commons-logging org.apache.httpcomponents/httpclient com.fasterxml.jackson.core/jackson-core]]])

我的命名空间如下所示:

(ns crawler.core
  (:require [itsy.core :refer :all])
  (:require [itsy.extract :refer :all])
  (:use  [amazonica.core]
         [amazonica.aws.s3]))

当我尝试使用(load crawler/core)将命名空间加载到lein&#39}时,我收到此错误:

CompilerException java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z, compiling:(amazonica/core.clj:1:1)

在线消息来源表明,这是一种依赖性不匹配。我该如何解决?

1 个答案:

答案 0 :(得分:1)

我把它排除在它而不是amazonica上并且它起作用了。还修复了core.clj中的NS表单。

project.clj:

(defproject blabla "0.1.0-SNAPSHOT"
   :description "FIXME: write description"
  :url "http://example.com/FIXME"
   :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [itsy "0.1.1" :exclusions [com.fasterxml.jackson.core/jackson-core]]  
                  [amazonica "0.3.22" :exclusions [commons-logging org.apache.httpcomponents/httpclient]]])

core.clj:

(ns blabla.core
  (:require [itsy.core :refer :all]
            [itsy.extract :refer :all]
            [amazonica.core :refer :all]
            [amazonica.aws.s3 :refer :all]))

(defn foo
   "I don't do a whole lot."
  [x]
   (println x "Hello, World!"))

在一般情况下处理这些情况

lein deps:tree

并添加排除项,直到只保留最新版本。