【问题标题】:Properly importing Apache Storm dependencies in Clojure在 Clojure 中正确导入 Apache Storm 依赖项
【发布时间】:2015-09-11 09:22:06
【问题描述】:

我尝试在我的 Clojure 项目中使用 Apache Storm 和 Redis。我的project.clj 看起来像这样:

(defproject storm "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.7.0"]
                 [org.apache.storm/storm-core "0.9.5"]
                 [com.taoensso/carmine "2.11.1"] ])

Redis 连接器模块中的命名空间声明为:

(ns storm.redis
  (:require [taoensso.carmine :as car]))

现在,由于某种原因,如果我尝试评估上述命名空间声明,我会收到一个奇怪的错误:

CompilerException java.lang.Exception: namespace 'taoensso.carmine' not found, compiling:(storm/redis.clj:1:22)

如果我将 project.clj 中的 Storm 依赖修改为

[storm "0.9.0.1"] ; Last available version on Clojars

然后一切正常。我做错了什么?

【问题讨论】:

    标签: clojure redis apache-storm


    【解决方案1】:

    我想我找到了解决办法。运行lein deps :tree 给了我这个:

    Possibly confusing dependencies found:
    [org.apache.storm/storm-core "0.9.5"] -> [commons-codec "1.6"]
     overrides
    [com.taoensso/carmine "2.11.1"] -> [commons-codec "1.10"]
    
    Consider using these exclusions:
    [com.taoensso/carmine "2.11.1" :exclusions [commons-codec]]
    

    carmine 中排除commons-codec 仍然会产生相同的错误,但反之亦然并从storm 中排除有效:

    [org.apache.storm/storm-core "0.9.5" :exclusions [commons-codec]]
    

    所以这意味着两个库都将使用较新版本的commons-codec

    似乎carmine 由于较低版本的依赖项而未能自行初始化(?)。这只是一个猜想,因为我不知道如何调试那些库初始化例程。

    更新: Carmine 库的作者 Peter Taoussanis 在回复 GitHub issue 时确认这是一个依赖问题,并提出了一些其他解决类似问题的方法。谢谢彼得!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-23
      • 1970-01-01
      • 1970-01-01
      • 2015-12-10
      • 1970-01-01
      相关资源
      最近更新 更多