我刚刚开始使用 clojure,我正在尝试构建一个小型网络应用程序。我想尝试打嗝,但似乎不起作用。我的代码如下。
项目.clj
(defproject WebTest "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:dependencies [[org.clojure/clojure "1.4.0"]
[compojure "1.1.5"]
[hiccup "1.0.3"]
[org.clojure/java.jdbc "0.2.3"]
[net.sourceforge.jtds/jtds "1.2.4"]
]
:plugins [[lein-ring "0.8.2"]
[lein-idea "1.0.1"]]
:ring {:handler WebTest.handler/app}
:profiles
{:dev {:dependencies [[ring-mock "0.1.3"]]}})
处理程序.clj
(ns WebTest.handler
(:use compojure.core)
(:require [compojure.handler :as handler]
[compojure.route :as route]
[WebTest.Content :as pages]
[hiccup.core :as templ]))
(defroutes app-routes
(GET "/" [] (templ/html [h1 "Hello world"]))
(GET "/Greeting/:name" [name] (str "<h1>Hello " name "</h1>"))
(GET "/Date/:year/:month/:day" [year month day] (str "<h1>It is " month "/" day "/" year "</h1>"))
(route/not-found "Not Found"))
(def app
(handler/site app-routes))
我得到的错误是
Exception in thread "main" java.io.FileNotFoundException: Could not locate hiccu
p/core/as__init.class or hiccup/core/as.clj on classpath:
at clojure.lang.RT.load(RT.java:432)
at clojure.lang.RT.load(RT.java:400)
at clojure.core$load$fn__4890.invoke(core.clj:5415)
at clojure.core$load.doInvoke(core.clj:5414)
随后是一个很长的堆栈跟踪。对我做错了什么有任何见解吗?
最佳答案
尝试像您一样要求 WebTest.Content 对我来说失败了,尽管如果我删除该内容,其余的工作正常:
(ns WebTest.handler
(:use compojure.core)
(:require [compojure.handler :as handler]
[compojure.route :as route]
;[WebTest.Content :as pages]
[hiccup.core :as templ]))
如果 handler.clj 的 ns
表单的 :require 部分中存在不匹配的 []
,那么您提到的错误就会出现,尽管它们不是由它引起的正如你所展示的。
关于clojure - 打嗝无法正常工作 : FileNotFoundException: Could not locate . ./as__init.class 或 ../as.clj 在类路径上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15888321/