Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Clojure 在类路径中找不到compojure_Clojure_Installation_Compojure - Fatal编程技术网

Clojure 在类路径中找不到compojure

Clojure 在类路径中找不到compojure,clojure,installation,compojure,Clojure,Installation,Compojure,我正在尝试各种入门示例,我可以得到一个基本的hello world示例,它在路由中使用基本HTML (ns hello-world (:use compojure.core ring.adapter.jetty) (:require [compojure.route :as route])) (defroutes example (GET "/" [] "<h1>Hello World Wide Web!</h1>")) (run-jetty exampl

我正在尝试各种入门示例,我可以得到一个基本的hello world示例,它在路由中使用基本HTML

(ns hello-world
  (:use compojure.core ring.adapter.jetty)
  (:require [compojure.route :as route]))

(defroutes example
  (GET "/" [] "<h1>Hello World Wide Web!</h1>"))

(run-jetty example {:port 8080})
然后我得到以下错误


线程“main”java.io.FileNotFoundException中的[null]异常:在类路径:(core.clj:1)上找不到compojure\uu init.class或compojure.clj

正如W55tKQbuRu28Q4xv在注释中提到的,在第二个示例中使用
(:use compojure…
)。您应该切换到
(:use compojure.core…
),然后可能会为您使用的其他功能引入一些附加依赖项(例如(我玩了一个compojure“Hello World”,遇到了这个问题(以及许多其他在我脑海中变得混乱的问题)。另一个复杂问题是,web上的许多Compojure文档已经过时。总之,以下是您希望遵循的步骤:

  • 具有的最新版本。请确保遵循github站点上的安装说明。(不要通过macports;它们的Leiningen已过期。)

  • 遵循Compojure的说明


  • 请注意,文件名不正确。它应该是src/hello_www/core.clj,而不是src/hello www/core.clj。

    您可能会提到(:使用compujure.core-ring.adapter.jetty)而不是(:使用compujure-ring.adapter.jetty)?intraweb中还有许多示例,包括(:使用compujure)。这似乎是以下所述的pre-Compojure 0.4示例。上面的问题仍然代表仍在遵循这些示例的人。我认为您的第二个示例缺少“[]”。它应该是(GET”/“[]”…感谢Julian,这是我可以使用的示例。但是,包含(html[:h1“foo”])的exmaples我不能。从Compojure版本0.4.0开始,hiccup.core现在是必需的。谢谢Michael,正是这样。我需要包含hiccup.core才能让(html[:h1“foo”])工作。
    (ns hello-world
      (:use compojure ring.adapter.jetty)
      (:require [compojure.route :as route]))
    
    (defroutes example
      (GET "/" []
        (html [:h1 "Hello World"])))
    
    (run-jetty example {:port 8080})