我試圖在2個文件分割代碼,每個都有它自己的命名空間。在此之後tutorial。Clojure的要求命名空間:「不知道如何從創建ISEQ:clojure.lang.Keyword」
但我得到這個錯誤: 異常在線程「主」 java.lang.IllegalArgumentException異常:不知道如何從創建ISEQ:clojure.lang.Keyword
我想這是因爲被包含的命名空間無法正確識別。
主文件:
(ns mytest2.handler
(:use compojure.core)
(:require [compojure.handler :as handler]
[compojure.route :as route]
[mytest2.views :as foo] ;<-- line causing error
[hiccup.core :refer (html)])
)
(defn layout [title & content]
(html
[:head [:title title]]
[:body content]))
(defn main-page []
(layout "My Blog"
[:h1 "My Blog"]
[:p "Welcome to my page"]))
(defroutes app-routes
(GET "/" [] (main-page))
(route/resources "/")
(route/not-found "Not Found"))
(def app
(handler/site app-routes))
; (println (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader))))
第二個文件:
(ns mytest2.views
:require [hiccup.core :refer (html)]
)
(defn layout [title & content]
(html
[:head [:title title]]
[:body content]))
(defn main-page []
(layout "My Blog"
[:h1 "My Blog"]
[:p "Welcome to my page"]))
(注意我複製的功能從mytest2.views在mytest2.handler測試他們不應該在mytest2。 .handler)。文件
路徑:
/mytest2/src/mytest2/handler.clj
/mytest2/src/mytest2/views.clj
(其中第一mytest2是該項目的名稱,第二個是lein自動創建的路徑的一部分)。
正如你在第一個文件中看到我打印的類路徑,以驗證/ mytest2/src目錄/ mytest2包括/,是的這是。
除了@ N2O的答案下面,不應該被稱爲符號HTML是[],而不是()?像'[hiccup.core:參閱[HTML]]' – georgek
@georgek兩種形式都相等的編譯器,但'[]'是常規的。 –