2013-04-08 42 views
2

我刚开始使用clojure,我试图构建一个小型的web应用程序。我想尝试打嗝,但似乎没有工作。我的代码如下。打嗝不工作:FileNotFoundException:找不到类路径上的../as__init.class或../as.clj

Project.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"]]}}) 

handler.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) 

一个很长的堆栈跟踪得出结论。任何洞察我做错了什么?

回答

3

试图要求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])) 

你提到会是这样的错误,如果有不匹配的地方[] S IN即:handler.clj的ns表单的require部分,尽管它们不是由它所引起的。

+0

这是对另一个实际上未被使用的文件的引用。我删除它,我仍然得到相同的错误。 – 2013-04-08 20:54:56

+2

我不得不同意Arthur,Clojure试图在hiccup.core命名空间下找到一个“as”文件。这会让我觉得在关键字前面缺少“:”。 – Mike 2013-04-08 23:49:32

+0

好吧,我把它从底部移到顶部,它开始工作。然后回到底部,它仍然有效。不知道为什么这有助于:( – 2013-04-09 15:33:05