&引用;警告:jar中不存在指定的主类。”;在组合Clojure+;Clojurescript重新框架项目
我已经开发了30多个Clojure项目,但这是我第一次尝试Clojurescript。我使用re-frame构建了一个SPA,现在我正在尝试为它创建uberjar。当我运行&引用;警告:jar中不存在指定的主类。”;在组合Clojure+;Clojurescript重新框架项目,clojure,clojurescript,re-frame,Clojure,Clojurescript,Re Frame,我已经开发了30多个Clojure项目,但这是我第一次尝试Clojurescript。我使用re-frame构建了一个SPA,现在我正在尝试为它创建uberjar。当我运行lein uberjar时,会收到以下错误消息: 警告:jar中不存在指定的主类。信息技术 可能无法按预期执行。gen类指令可以是 包含main方法的命名空间中缺少,或者 尚未对命名空间进行AOT编译 我已经设置了项目.clj的服务器端部分,类似于其他Clojure项目 所有服务器端源文件都位于src/clj中 所有Cloj
lein uberjar
时,会收到以下错误消息:
警告:jar中不存在指定的主类。信息技术
可能无法按预期执行。gen类指令可以是
包含main方法的命名空间中缺少,或者
尚未对命名空间进行AOT编译
我已经设置了项目.clj的服务器端部分,类似于其他Clojure项目
- 所有服务器端源文件都位于
src/clj
中
- 所有Clojurescript源文件都位于
src/cljs
main
位于文件server\u core.clj
中,该文件位于src/clj/ordering
中
(:gen class)
出现在server\u core.clj
中
-main
存在于服务器\u core.clj
中:
(defn-main)
[&args]
(主要部分)
project.clj
包括以下uberjar指令:
:uberjar {:aot :all
:source-paths ["src/clj"]
:env {:production true}
:main ordering.server-core
:hooks [leiningen.cljsbuild]}}
project.clj
中的main
和target path
指令如下:
:main ^:skip-aot ordering.server-core
:target-path "target/%s")
我想创建这个uberjar,将其包含在Dockerfile中,就像我处理其他Clojure项目一样
更新:添加project.clj
(defproject ordering "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.9.0"]
[org.clojure/clojurescript "1.10.238"]
[org.clojure/core.async "0.4.474"]
;; clojurescript 3rd party
[re-frame/re-frame "0.10.5"]
[day8.re-frame/test "0.1.5"]
[day8.re-frame/http-fx "0.1.6"]
[re-frame-datatable "0.6.0"]
[com.rpl/specter "1.1.1"]
[cljsjs/firebase "3.5.3-0"]
[reagent "0.8.0"]
[expound "0.6.0"]
[metosin/reitit "0.1.1-SNAPSHOT"]
[metosin/reitit-ring "0.1.1-SNAPSHOT"]
[metosin/reitit-spec "0.1.1-SNAPSHOT"]
[metosin/muuntaja "0.5.0"]
[cljs-ajax "0.7.3"]
[re-com "2.1.0"]
[garden "1.3.5"]
[ring-logger-timbre "0.7.5"]
[ring/ring-jetty-adapter "1.6.2"]
;; common
[clj-time "0.13.0"]
[cheshire "5.7.1"]
[com.taoensso/timbre "4.10.0"]
[commons-codec/commons-codec "1.11"]
;; google
[com.google.cloud/google-cloud-storage "1.27.0"]
[com.google.firebase/firebase-admin "6.0.0"]
[ns-tracker "0.3.1"]]
:plugins [[lein-cljsbuild "1.1.7"]
[lein-garden "0.3.0"]
[lein-ring "0.9.7"]]
:ring {:init ordering.server-core/init
:destroy ordering.server-core/destroy
:handler ordering.handler/app
:auto-reload? true
:port 3000
:nrepl {:start? true}}
:min-lein-version "2.5.3"
:source-paths ["src/cljs" "src/clj"]
:test-paths ["test/cljs" "test/clj"]
:clean-targets ^{:protect false} ["resources/public/js/compiled" "target"
"test/js"
"resources/public/css"]
:figwheel {:css-dirs ["resources/public/css"]}
:garden {:builds [{:id "screen"
:source-paths ["src/styles"]
:stylesheet ordering.screen/screen
:compiler {:output-to "resources/public/css/screen.css"
:pretty-print? true}}]}
:prep-tasks [["garden" "once"]]
:repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}
:profiles
{:dev
{:dependencies [[fipp/fipp "0.6.12"]
[binaryage/devtools "0.9.10"]
[figwheel-sidecar "0.5.16"]
[re-frisk "0.5.4"]
[com.cemerick/piggieback "0.2.2"]
[doo "0.1.10"]
[javax.servlet/servlet-api "2.5"]
[clj-http "3.9.0"]
[ring/ring-mock "0.3.1"]]
:plugins [[lein-figwheel "0.5.16"]
[lein-doo "0.1.10"]]
}
:hooks [leiningen.cljsbuild]
:uberjar {:aot :all
:source-paths ["src/clj"]
:env {:production true}
:main ordering.server-core
:hooks [leiningen.cljsbuild]}}
:cljsbuild
{:builds
[{:id "dev"
:source-paths ["src/cljs"]
:figwheel {:on-jsload "ordering.core/mount-root"}
:compiler {:main ordering.core
:closure-defines {"goog.DEBUG" true
"clairvoyant.core.devmode" true}
:output-to "resources/public/js/compiled/dev/app.js"
:output-dir "resources/public/js/compiled/dev/out"
:asset-path "js/compiled/dev/out"
:source-map-timestamp true
:preloads [devtools.preload
re-frisk.preload]
:external-config {:devtools/config {:features-to-install :all}}
}}
{:id "min"
:source-paths ["src/cljs"]
:compiler {:main ordering.core
:output-to "resources/public/js/compiled/app.js"
:output-dir "resources/public/js/compiled/out"
:optimizations :advanced
:asset-path "js/compiled/out"
:closure-defines {goog.DEBUG false}
:pretty-print false}}
{:id "test"
:source-paths ["src/cljs" "test/cljs"]
:compiler {:main ordering.runner
:output-to "resources/public/js/compiled/test.js"
:output-dir "resources/public/js/compiled/test/out"
:optimizations :none}}
]}
:doo {:build "test"
:alias {:default [:chrome]}}
:main ^:skip-aot ordering.server-core
:target-path "target/%s")
我不确定您的具体问题的原因,但我最近也开始使用CLJS,它可以与doo
测试框架和figwheel一起使用
~/expr/cljs-template > lein doo phantom test once
;; ======================================================================
;; Testing with Phantom:
doorunner - beginning
doorunner - end
Testing tst.flintstones.dino
Beginning dino tests...
globalObject: #js {:a 1, :b 2, :c 3}
(-> % .-b (+ 5) => 7
(js/makeDino) => #js {:desc blue dino-dog, :says #object[Function]}
dino.desc => blue dino-dog
dino.says(5) => Ruff-Ruff-Ruff-Ruff-Ruff!
Finished dino tests...
Testing tst.flintstones.wilma
Beginning wilma tests...
Finished wilma tests...
Beginning wilma tests...
wilmaPhony/stats: #js {:lipstick red, :height 5.5}
wilma => #js {:desc patient housewife, :says #object[Function]}
Finished wilma tests...
Testing tst.flintstones.pebbles
Beginning pebbles tests...
Finished pebbles tests...
Ran 5 tests containing 10 assertions.
0 failures, 0 errors.
它还可以与lein uberjar一起使用
:
~/expr/cljs-template > lein uberjar
Created /home/alan/expr/cljs-template/target/flintstones-0.1.0-SNAPSHOT.jar
Created /home/alan/expr/cljs-template/target/flintstones-0.1.0-SNAPSHOT-standalone.jar
您可以通过肉眼发现与您的项目之间的差异,或者您可以通过频繁暂停lein clean以增量方式粘贴代码;lein uberjar
查看什么时候新的东西导致它失败。在有疑问时,以及每次更改project.clj
时,请务必执行clean
步骤,否则旧的构建工件可能会把事情搞得一团糟
我对您发现的原因很感兴趣。可能什么都不是,但基于server_core.clj位置的server core名称空间似乎是“ordering”。但是:uberjar概要文件中的:main指向“annotation client.server core”。这可能是个问题吗?@jas,你说得对。我在SO帖子上打错了。我已更新以反映正确的名称。我添加了完整的
项目。clj
还有其他想法吗?为什么跳过aot
?非常有用的输入。我会试试看,然后告诉你进展如何。