clojure - 奇怪的 super war 行为

标签 clojure war compojure

我正在为我的测试 web 应用程序执行 lein uberwar ,但收到以下奇怪的错误:

Exception in thread "main" java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.Symbol (servlet.clj:1)

servlet.clj 包含以下内容:

(ns test.servlet
  (:use ring.util.servlet)
  (:require test.routes :as routes)
  (:gen-class :extends javax.servlet.http.HttpServlet))

(defservice routes/app-routes)

test.routes 文件包含:

(ns test.routes
  (:use compojure.core)
  (:require [compojure.route :as route]
            [compojure.handler :as handler]))


(defroutes app-routes
  (GET "/" [] {:status 200
               :headers {"Content-Type" "text/html"}
               :body "<h1>Hello World</h1>"})
  (route/files "/" {:root "static"})
  (ANY "/:s" [s] (str "page-not-found" s)

;; For lein ring-server
;(def test-handler
;  (handler/site app-routes))

奇怪的是,如果我替换该行

(:require test.routes :as routes)

与:

(:require test.routes)

然后打电话

 (defservice test.routes/app-routes)

在 servlet.clj 中,WAR 编译良好,并且在 tomcat 中完美运行。我的代码中是否存在一些我看不到的错误?为什么我需要调用 test.routes/... 而不仅仅是 paths/...?

最佳答案

您需要将其放入向量中:

(:require [test.routes :as routes])

关于clojure - 奇怪的 super war 行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6251614/

相关文章:

Clojure 的重构技术

java - Java 存档文件结构规范在哪里?

clojure - 在ring/compojure中使用路由/文件与路由/资源

clojure - 如何在最新版本的 ring/compojure 中使用 ring anti-forgery/CSRF token ?

jQuery CORS 请求因 FireFox 中的预检选项请求而终止

clojure - 前缀列表中的库名称不得包含句点

optimization - Clojure 中的快速复数运算

java - 在tomcat服务器中运行war文件时出错

java - EAR 库的类为 WAR 成员抛出 ClassNotFoundException(不同)

emacs - 如何在 Clojure 代码上执行与 eval-last-sexp 等效的操作