【问题标题】:Unable to resolve clj-http无法解析 clj-http
【发布时间】:2015-10-06 18:08:50
【问题描述】:

我想用clj-http,所以我用lein创建了一个项目,这些依赖在project.clj:

(defproject app "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:main app.core
: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"]
            [clj-http "2.0.0"]])

src/app/core.clj

(ns app.core
  (:require [clj-http.client :as client]))

(println client)

(defn -main
  [& args])

当我使用lein clean && lein deps && lein run 时,我收到一条错误消息:

Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: client in this context, compiling:(app/core.clj:4:1)
    at clojure.lang.Compiler.analyze(Compiler.java:6543)
    at clojure.lang.Compiler.analyze(Compiler.java:6485)
    at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3791)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6725)
    at clojure.lang.Compiler.analyze(Compiler.java:6524)
    at clojure.lang.Compiler.analyze(Compiler.java:6485)

lein version 输出:

Leiningen 2.5.3 on Java 1.8.0_45 Java HotSpot(TM) 64-Bit Server VM

我做错了吗?我完全按照 clj-http 文档进行操作。

谢谢。

【问题讨论】:

    标签: java clojure leiningen clj-http


    【解决方案1】:

    要求[clj-http.client :as client] 允许您使用client 作为前缀来引用该命名空间中定义的变量。例如,你可以说

    (client/get "http://example.com/")
    

    并得到回复。

    但是,这种用法与使用符号 client 来指代 Var 或本地无关,因此这是行不通的:

    (println client)
    

    client 只是在当前命名空间中注册的命名空间别名,无法计算。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-15
      • 2023-02-03
      • 1970-01-01
      相关资源
      最近更新 更多