Hiccup不工作:FileNotFoundException:无法定位../as__init.class或../as.clj在类路径 [英] Hiccup not working : FileNotFoundException: Could not locate ../as__init.class or ../as.clj on classpath

查看:190
本文介绍了Hiccup不工作:FileNotFoundException:无法定位../as__init.class或../as.clj在类路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始clojure,我试图建立一个小的网络应用程序。我想尝试打嗝,但它似乎没有工作。我的代码如下。



Project.clj

 (defproject WebTest 0.1.0-SNAPSHOT
:descriptionFIXME:write description
:urlhttp://example.com/FIXME
:dependencies [[org.clojure / clojure 1.4.0]
[compojure1.1.5]
[hiccup1.0.3]
[org.clojure / java.jdbc0.2.3]
[lein-ring0.8.2]
[lein-idea1.0.1 ]]
:ring {:handler WebTest.handler / app}
:profiles
{:dev {:dependencies [[ring-mock0.1.3]]}})

handler.clj

 (ns WebTest.handler 
(:use compojure.core)
(:require [compojure.handler:as handler]
[compojure.route:as route]
] [b] [b] [b] [b] [b] [b] [b] [b] html [h1Hello world]))
(GET/ Greeting /:name[name](str< h1> Helloname< / h1>))
GET/ Date /:year /:month /:day[年月日](str< h1>是month/day/year< / h1>))
(路径/未找到未找到))

(def app
(处理程序/站点应用程序路由))
pre>

我得到的错误是

 线程中的异常mainjava.io.FileNotFoundException:无法在类路径上找到hiccu 
p / core / as__init.class或hiccup / core / as.clj:
at clojure.lang.RT.load(RT.java :432)
at clojure.lang.RT.load(RT.java:400)
在clojure.core $ load $ fn__4890.invoke(core.clj:5415)
在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 ]))

您提到的错误是,如果存在不匹配的 [] s在handler.clj的 ns 形式的require部分,虽然它们不是由它显示它。


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?

解决方案

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.

这篇关于Hiccup不工作:FileNotFoundException:无法定位../as__init.class或../as.clj在类路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆