导致 uberimage 构建失败的架构

Schema causing uberimage build failure

我正在用 Clojure 开发一个简单的 hello world web 应用程序。但是,在我将 Schema 库添加到我的项目后,我在尝试使用 lein uberjar 构建 uberjar 时开始收到以下错误。奇怪的是,应用程序在使用 lein dev.

启动时仍然通过了单元测试并且运行没有错误

java.lang.RuntimeException: Unable to resolve symbol: missing-required-key in this context, compiling:(server/api.clj:21:17) at clojure.lang.Compiler.analyze(Compiler.java:6464) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$VectorExpr.parse(Compiler.java:3126) at clojure.lang.Compiler.analyze(Compiler.java:6447) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$MapExpr.parse(Compiler.java:2981) at clojure.lang.Compiler.analyze(Compiler.java:6453) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$MapExpr.parse(Compiler.java:2981) at clojure.lang.Compiler.analyze(Compiler.java:6453) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.access0(Compiler.java:38) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6050) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6100) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6100) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6100) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6100) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5217) at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3846) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6642) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5217) at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3846) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6642) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.access0(Compiler.java:38) at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:538) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler.compile1(Compiler.java:7221) at clojure.lang.Compiler.compile(Compiler.java:7292) at clojure.lang.RT.compile(RT.java:398) at clojure.lang.RT.load(RT.java:438) at clojure.lang.RT.load(RT.java:411) at clojure.core$load$fn__5066.invoke(core.clj:5641) at clojure.core$load.doInvoke(core.clj:5640) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invoke(core.clj:5446) at clojure.core$compile$fn__5071.invoke(core.clj:5652) at clojure.core$compile.invoke(core.clj:5651) at user$eval9$fn__16.invoke(form-init1857067608391167398.clj:1) at user$eval9.invoke(form-init1857067608391167398.clj:1) at clojure.lang.Compiler.eval(Compiler.java:6703) at clojure.lang.Compiler.eval(Compiler.java:6693) at clojure.lang.Compiler.load(Compiler.java:7130) at clojure.lang.Compiler.loadFile(Compiler.java:7086) at clojure.main$load_script.invoke(main.clj:274) at clojure.main$init_opt.invoke(main.clj:279) at clojure.main$initialize.invoke(main.clj:307) at clojure.main$null_opt.invoke(main.clj:342) at clojure.main$main.doInvoke(main.clj:420) at clojure.lang.RestFn.invoke(RestFn.java:421) at clojure.lang.Var.invoke(Var.java:383) at clojure.lang.AFn.applyToHelper(AFn.java:156) at clojure.lang.Var.applyTo(Var.java:700) at clojure.main.main(main.java:37) Caused by: java.lang.RuntimeException: Unable to resolve symbol: missing-required-key in this context at clojure.lang.Util.runtimeException(Util.java:221) at clojure.lang.Compiler.resolveIn(Compiler.java:6940) at clojure.lang.Compiler.resolve(Compiler.java:6884) at clojure.lang.Compiler.analyzeSymbol(Compiler.java:6845) at clojure.lang.Compiler.analyze(Compiler.java:6427) ... 153 more Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: missing-required-key in this context, compiling:(server/api.clj:21:17) at clojure.lang.Compiler.analyze(Compiler.java:6464) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$VectorExpr.parse(Compiler.java:3126) at clojure.lang.Compiler.analyze(Compiler.java:6447) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$MapExpr.parse(Compiler.java:2981) at clojure.lang.Compiler.analyze(Compiler.java:6453) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$MapExpr.parse(Compiler.java:2981) at clojure.lang.Compiler.analyze(Compiler.java:6453) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.access0(Compiler.java:38) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6050) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6100) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6100) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6100) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6100) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5217) at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3846) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6642) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5217) at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3846) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6642) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.access0(Compiler.java:38) at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:538) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler.compile1(Compiler.java:7221) at clojure.lang.Compiler.compile(Compiler.java:7292) at clojure.lang.RT.compile(RT.java:398) at clojure.lang.RT.load(RT.java:438) at clojure.lang.RT.load(RT.java:411) at clojure.core$load$fn__5066.invoke(core.clj:5641) at clojure.core$load.doInvoke(core.clj:5640) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invoke(core.clj:5446) at clojure.core$compile$fn__5071.invoke(core.clj:5652) at clojure.core$compile.invoke(core.clj:5651) at user$eval9$fn__16.invoke(form-init1857067608391167398.clj:1) at user$eval9.invoke(form-init1857067608391167398.clj:1) at clojure.lang.Compiler.eval(Compiler.java:6703) at clojure.lang.Compiler.eval(Compiler.java:6693) at clojure.lang.Compiler.load(Compiler.java:7130) at clojure.lang.Compiler.loadFile(Compiler.java:7086) at clojure.main$load_script.invoke(main.clj:274) at clojure.main$init_opt.invoke(main.clj:279) at clojure.main$initialize.invoke(main.clj:307) at clojure.main$null_opt.invoke(main.clj:342) at clojure.main$main.doInvoke(main.clj:420) at clojure.lang.RestFn.invoke(RestFn.java:421) at clojure.lang.Var.invoke(Var.java:383) at clojure.lang.AFn.applyToHelper(AFn.java:156) at clojure.lang.Var.applyTo(Var.java:700) at clojure.main.main(main.java:37) Caused by: java.lang.RuntimeException: Unable to resolve symbol: missing-required-key in this context at clojure.lang.Util.runtimeException(Util.java:221) at clojure.lang.Compiler.resolveIn(Compiler.java:6940) at clojure.lang.Compiler.resolve(Compiler.java:6884) at clojure.lang.Compiler.analyzeSymbol(Compiler.java:6845) at clojure.lang.Compiler.analyze(Compiler.java:6427) ... 153 more Compilation failed: Subprocess failed

下面是我使用schema的源文件。为简洁起见,我省略了其余的源文件,但如果有人想查看其余部分,请询问。

(ns server.api
  (:require [aleph.http :as http]
            [compojure.api.sweet :refer :all]
            [compojure.route :as route]
            [com.stuartsierra.component :as component]
            [ring.middleware.reload :refer [wrap-reload]]
            [ring.util.http-response :refer :all]
            [schema.core :as s]
            [server.logging :refer [wrap-exception-logging wrap-request-logging] :as log]))

(s/defschema Greeting
  {:hello s/Str
   s/Keyword s/Any})

(defn app [db]
  (api
   {:format {:formats [:json-kw]}}
   (middlewares [wrap-request-logging
                 wrap-exception-logging]
                (swagger-ui "/docs" :swagger-docs "/endpoints")
                (swagger-docs "/endpoints"
                 {:info {:title "Hello World Api"}})

                (GET* "/greet" []
                      :summary "Greets someone by name."
                      :description "Greets a person by name, telling them about
                                    the database configuration we're using as well."
                      :return Greeting
                      :query-params [name :- s/Str]
                      (ok {:hello name :with-db db}))

                (route/not-found (not-found {:error "Page not found."})))))

(defrecord Api
  [port env db logger]
  component/Lifecycle

  (start [{:keys [connection] :as component}]
    (if connection
      component
      (do (log/info "Starting Api at port" port "with env" env)
          (let [application (app db)
                handler (if (= env :dev) (wrap-reload application) application)
                conn (http/start-server handler {:port port :join? false})]
            (assoc component :connection conn)))))

  (stop [{:keys [connection] :as component}]
    (if-not connection
      component
      (do (log/info "Stopping Api")
          (.close connection)
          (assoc component :connection nil)))))

(defn new-api [port env]
  (->Api port env nil nil))

我已经尝试过禁用 AOT 编译,因为这似乎是正常编译和构建 uberjar 之间的主要区别,但不是。我还在 Schema 源代码中查找了 'missing-required-key' 键,并确保它被正确引用,看起来确实如此,因为如果我更改它,Schema 的测试就会开始失败。

与正常编译相比,创建uberjar的编译过程还有什么不同?还有什么我可以尝试的吗?

我以前从未见过该错误(我们使用架构和 uberjar 部署了所有服务)。看起来第 21 行是 swagger-docs 中间件;您可以尝试删除它并查看是否可以解决问题吗?

我确实反应你用:refer :all,最好用:refer [list of symbols used in code]。这可能不是这里的错误,但对于那些不太了解这些库的人来说,它使代码更容易深入研究。

我查看了 compojure.api.sweet-命名空间,发现 Zach Tellmans Potemkin 用于 "import" 来自不同命名空间的所有函数到您的命名空间 service.api。也许这会在创建 jar 时出现问题。

您能否尝试通过将此行添加到要求中来从其原始名称空间中要求 swagger-uiswagger-docs

[compojure.api.swagger swagger-ui swagger-docs]

如果这不起作用但至少给出了另一条错误消息(也许)尝试 require 明确使用的所有其他符号。

我不确定这是否有帮助,但尝试 运行ning lein deps :tree 并查看传递依赖项是什么。可能是多个库依赖于同一依赖项的不同的、不兼容的版本。我以前 运行 了解过这个,但我不知道为什么它只会在打包到 uberjar 中时发生。

根本原因是给 swagger-docs 路由一个无效输入(没有给定 :version,见 https://github.com/metosin/ring-swagger/blob/master/src/ring/swagger/swagger2_schema.clj#L13)。添加后,它会按预期工作。

不过,给定的异常确实很糟糕,现在已在最新的 SNAPSHOT 中修复 - 对缺失的字段使用默认值,因此不会对其进行编译时模式检查。

此外,建议不要对整个应用程序进行 AOTing。参见 https://github.com/metosin/compojure-api/issues/129