gpt4 book ai didi

java - 无法解析 clj-http

转载 作者:行者123 更新时间:2023-12-01 22:04:53 24 4
gpt4 key购买 nike

我想使用 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 版本输出:

Java 1.8.0_45 Java HotSpot(TM) 64 位服务器 VM 上的 Leiningen 2.5.3

我是不是做错了什么?我完全遵循 clj-http 文档。

谢谢。

最佳答案

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

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

并得到回复。

但是,这种用法与使用符号 client 来引用 Var 或本地变量无关,因此这不起作用:

(println client)

client 只是在当前命名空间中注册的命名空间别名,无法对其进行求值。

关于java - 无法解析 clj-http,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32976699/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com