【问题标题】:How do I fix this dependency issue in Clojure?如何在 Clojure 中解决此依赖问题?
【发布时间】:2015-08-04 22:29:54
【问题描述】:

我在解决两个不同包的依赖项发生冲突的问题时遇到了很多麻烦。我的 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 的 repl 中时,我收到此错误:

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

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

【问题讨论】:

  • 您能否包含运行“lein deps :tree”的输出部分,其中提到了 itsy 或 amazonica。输出中很可能还会建议排除

标签: clojure jackson dependencies leiningen amazonica


【解决方案1】:

我将排除项放在 itsy 而不是 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

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

【讨论】:

  • 谢谢亚瑟。今晚晚些时候我会试试这个。实际上,我确实按照您的建议执行了有关运行 lein deps :tree 并添加排除项的操作,直到它停止提出建议为止。这就是我达到上述目的的方式。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-12-02
  • 1970-01-01
  • 2019-09-02
  • 2017-06-24
  • 1970-01-01
  • 2019-06-07
  • 2023-02-21
相关资源
最近更新 更多