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中的defroutes宏_Clojure_Macros_Compojure - Fatal编程技术网

Clojure 无法使用compojure中的defroutes宏

Clojure 无法使用compojure中的defroutes宏,clojure,macros,compojure,Clojure,Macros,Compojure,运行此代码时: (:use 'compojure.core) (keys (ns-publics 'compojure.core)) (defroutes app-routes (GET "/" [] "Hello World") (route/resources "/") (route/not-found "Not Found")) (:使用'compojure.core] (键(ns publics的复合核心)) (取消路线应用程序路线

运行此代码时:

(:use 'compojure.core) (keys (ns-publics 'compojure.core)) (defroutes app-routes (GET "/" [] "Hello World") (route/resources "/") (route/not-found "Not Found")) (:使用'compojure.core] (键(ns publics的复合核心)) (取消路线应用程序路线) (获取“/”[“你好,世界”) (路线/资源“/) (路由/未找到“未找到”)) 我得到了这个信息:

CompilerException java.lang.RuntimeException: Unable to resolve symbol: defroutes in this context, compiling:(restful_clojure\routes.clj:5:1) CompilerException java.lang.RuntimeException:无法解析符号:在此上下文中定义路由,正在编译:(restful\u clojure\routes.clj:5:1) 但当我跑步时:

(keys (ns-publics 'compojure.core)) (键(ns publics的复合核心)) 它显示宏的定义:

(defroutes PUT POST routing routes make-route let-routes DELETE ANY let-request GET HEAD PATCH context OPTIONS) (defroutes PUT POST路由使路由let路由删除任何let请求获取头部补丁上下文选项) Clojure有方法、和。它们用于处理不同的名称空间

:use
是一个函数,它可以像函数一样运行(在您的示例中,它应该返回
nil
),但不执行您想要的操作

混淆可能是因为中,您可以使用相应的关键字“嵌入”这些函数的行为


有关名称空间的更多阅读,请参见此。

能否发布整个文件并描述如何运行代码?我刚刚在类路径上用compojure在终端中启动了REPL,它可以正常工作。