Clojure中的Compojure示例不起作用
我正在编写Clojure in Action第232页的Compojure示例Clojure中的Compojure示例不起作用,clojure,leiningen,compojure,Clojure,Leiningen,Compojure,我正在编写Clojure in Action第232页的Compojure示例 (ns compojure-test.core (:gen-class) (:use compojure)) (defroutes hello (GET "/" (html [:h1 "Hello world"])) (ANY "*" [404 "Page not found"])) (run-server {:port 8080} "/*" (servlet hello)) 但当我尝试运行它时
(ns compojure-test.core
(:gen-class)
(:use compojure))
(defroutes hello
(GET "/" (html [:h1 "Hello world"]))
(ANY "*" [404 "Page not found"]))
(run-server {:port 8080} "/*" (servlet hello))
但当我尝试运行它时:
$ lein run
Exception in thread "main" java.lang.ClassNotFoundException: compojure-test.core
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
...
看来这项声明
(:use compojure)
我还听说compojure的最新版本之间发生了重大变化。设置此compojure应用程序时我做错了什么?是否有一个好的在线教程可以帮助我启动和运行?您可能想尝试将您的
use
语句更改为:
(:使用compojure.core)
应该这样做
不久前,我为compojure创建了一个样板模板,其中有一个您可以看到的工作示例
更好的是,如果您正在使用Leiningen(您应该这样做),您可以简单地创建一个新的compojure项目,如下所示:
$lein new compojure hello world
有关更多信息,请查看compojure。您可能希望尝试将您的
use
语句更改为:
(:使用compojure.core)
应该这样做
不久前,我为compojure创建了一个样板模板,其中有一个您可以看到的工作示例
更好的是,如果您正在使用Leiningen(您应该这样做),您可以简单地创建一个新的compojure项目,如下所示:
$lein new compojure hello world
更多信息,请访问compojure。谢谢您的回答,也谢谢您的样板。快速n00b问题,如何设置project.clj以及如何在localhost上运行它?我建议使用lein模板。创建项目后,您的project.clj应该就可以运行了。然后在您的项目根目录中运行此命令:
lein-ring-server
,它将打开您的webapp根目录下的浏览器。一旦这样做了,你所需要的就是实现你的代码。谢谢你的回答,也谢谢你的样板。快速n00b问题,如何设置project.clj以及如何在localhost上运行它?我建议使用lein模板。创建项目后,您的project.clj应该就可以运行了。然后在您的项目根目录中运行此命令:lein-ring-server
,它将打开您的webapp根目录下的浏览器。一旦这样做了,你所需要的就是实现你的代码。