[英]Fastest way to try out a new library in a REPL using Leinengen with Clojure
新的clojure開發人員嘗試在REPL中嘗試使用HTTP套件clojure庫 。
我在leinengen創建了一個新項目, lein new app kit-expt
。
然后,我修改了project.clj中的:dependencies塊以包含[http-kit "2.2.0"]
。
然后,我運行lein deps
,然后運行lein repl
。
在REPL中,我嘗試運行(:require [org.httpkit.client :as http])
。
但是,當我運行它時,我得到了錯誤
CompilerException java.lang.ClassNotFoundException: org.httpkit.client, compiling:(/private/var/folders/cs/b0kcg6fx0335crbvn6xtgq7xl5c29j/T/form-init7575648818353088270.clj:1:1)
我究竟做錯了什么?
您的環境中似乎有問題。 如果我運行它(Ubuntu 16.04),它將很好地工作:
(require '[org.httpkit.client :as http])
(pr-str (clojure.core/deref (http/get "http://google.com"))))
=> "{:opts {:method :get, :url \"http://www.google.com/\", :query-params nil, :form-params nil, :trace-re".....
正如Micah指出的那樣,在REPL中,您需要以上形式的require
。 請注意,它沒有前導冒號,並且在左方括號之前確實有一個單引號。 還必須在括號內,而不是方括號。
在ns
形式(我更喜歡)中,一切都有相反的約定:
(ns tst.clj.core
(:use clj.core clojure.test tupelo.test)
(:require
[tupelo.core :as t]
[org.httpkit.client :as http] ))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.