2015-10-06 29 views
0

我想用CLJ-HTTP,所以我在project.clj创建了一个项目与这些相关雷音:无法解析CLJ-HTTP

(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文档。

谢谢。

回答

3

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

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

并得到回应。

这种用法,但是,无关使用符号client指一个VAR或本地的,所以这是行不通的:

(println client) 

client只是在注册空间别名当前命名空间,以及那些不能被评估。