Hiccup not working : FileNotFoundException: Could not locate ../as__init.class or ../as.clj on classpath

送分小仙女□ 提交于 2020-02-25 01:26:55

问题


I'm just beginning with clojure and I'm trying to build a small web app. I wanted to try out hiccup but it doesn't seem to be working. My code is below.

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

And the error that I get is

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)

A very long stack trace follows that. Any insight into what I'm doing wrong?


回答1:


Attempting to require WebTest.Content as you do fails for me, Though the rest works fine if I remove that one:

(ns WebTest.handler
  (:use compojure.core)
  (:require [compojure.handler :as handler]
            [compojure.route :as route]
            ;[WebTest.Content :as pages]
            [hiccup.core :as templ])) 

The error you mention would be the case if there where mismatched []s in the :require section of handler.clj's ns form though they are not caused by it as you show it.



来源:https://stackoverflow.com/questions/15888321/hiccup-not-working-filenotfoundexception-could-not-locate-as-init-class-o

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!