clojure - 打嗝无法正常工作 : FileNotFoundException: Could not locate . ./as__init.class 或 ../as.clj 在类路径上

标签 clojure hiccup

我刚刚开始使用 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/

相关文章:

clojure:获取向量大小的时间为 O(1)

intellij-idea - 如何在 IntelliJ 中手动下载 ClojureDocs for Cursive?

clojure - 如何在 ClojureScript 中使用 Reanimated "worklet"指令?

Clojure:Hiccup 表单处理程序

clojure - 将 Clojure 解决方案推广到 Euler #1

dictionary - Clojure:如果键存在,则惯用更新 map 的值

clojure - Hiccup:如何在试剂中显示引号?

clojure - 使用打嗝渲染异步脚本标签

clojure - 使用 Hiccup 自动转义 HTML,这可能吗?

clojure - 有没有 html 解析器来打嗝结构?