代码之家  ›  专栏  ›  技术社区  ›  Xian

在类路径中找不到compojure

  •  10
  • Xian  · 技术社区  · 16 年前

    我正在尝试各种入门的例子,我可以得到一个基本的helloworld的例子与基本的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})
    

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

    然后我得到以下错误

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

    2 回复  |  直到 16 年前
        1
  •  9
  •   Michał Marczyk    16 年前

    正如W55tKQbuRu28Q4xv在评论中提到的,您使用 (:use compojure ...) (:use compojure.core ...) 然后可能会为您使用的其他功能引入一些附加的依赖项(例如 hiccup

    我猜您在使用compojure0.4时,正在尝试遵循一些为compojure0.3编写的教程。后者不包括 compojure ring 打嗝 ).

    幸运的是,在0.3上有很好的资源->0.4过渡,例如。 this blog entry this follow-up discussion 在Compojure的Google组上查找勘误表和其他详细信息。

        2
  •  1
  •   Julien Chastang    16 年前

    我玩了一个复合的“你好世界”,并有这个问题(以及许多其他正在我的大脑混乱)。另一个复杂的问题是web上的许多Compojure文档已经过时了。总之,你要遵循以下步骤:

    1. 有最新版本的 Leiningen . 确保遵循github站点上的安装说明(做 通过macports;他们的Leiningen已经过时了。)

    2. here .

    注意