[英]Clojure: using library functions from REPL
我剛開始使用Clojure並且從未使用過Java
我理解如何從終端創建和運行leiningen項目,但我無法理解如何在運行命令之前在REPL中加載庫。
我正在嘗試使用clj-webdriver構建一個簡單的Web剪貼器; 我的原始文件看起來像這樣
(ns prova.core (:gen-class))
(use 'clj-webdriver.taxi)
(set-driver! {:browser :firefox})
(defn -main
[& args]
(to "https://github.com/login")
(input-text "#login_field" "email")
(input-text "#password" "psw")
(click "input[name='commit']")
)
最接近我(想)必須實現它的是進入webdriver src文件夾並嘗試此命令
penta@laptop:~/clj-webdriver-master/src/clj_webdriver$ clojure
Clojure 1.4.0
user=> (use 'taxi)
但它回來了
FileNotFoundException Could not locate taxi__init.class or taxi.clj on classpath: clojure.lang.RT.load (RT.java:432)
即使你在同一個文件夾中,文件taxy.clj確實存在。
那么,運行可以使用庫函數的REPL的過程是什么?
非常感謝
看看leiningen構建工具,根據網站的說明安裝它並制作一個新項目。
lein new myproject
cd myproject
然后編輯project.clj
在其中添加clj-webdriver作為依賴項:
(defproject myproject "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.5.1"]
[clj-webdriver "0.6.0"]])
然后鍵入lein repl
,REPL將在類路徑上使用clj-webdriver旋轉。 您現在應該能夠像在示例中那樣繼續。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.