Clojure Lein uberjar在简单'-主要';用法,但也许我不知道';我不完全明白';他在干什么?
我使用以下方法创建了一个简单的示例:Clojure Lein uberjar在简单'-主要';用法,但也许我不知道';我不完全明白';他在干什么?,clojure,leiningen,Clojure,Leiningen,我使用以下方法创建了一个简单的示例: %> lein new lein-check 我只修改了代码,使它现在有一个“main”: (defproject lein-check "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME" :license {:name "Eclipse Public License" :url "http
%> lein new lein-check
我只修改了代码,使它现在有一个“main”:
(defproject lein-check "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:main "lein-check.core"
:dependencies [[org.clojure/clojure "1.4.0"]])
(ns lein-check.core
(:gen-class))
(defn -main
"I don't do a whole lot."
[& args]
(println "Hello, World!"))
但是我第一次运行lein uberjar
时,即使在清理
之后,我也会得到以下信息:
Compiling lein-check.core
Exception in thread "main" java.lang.ClassCastException:
java.lang.String cannot be cast to clojure.lang.Symbol
at clojure.core$find_ns.invoke(core.clj:3659)
at clojure.core$load_one.invoke(core.clj:5228)
at clojure.core$compile$fn__4895.invoke(core.clj:5426)
at clojure.core$compile.invoke(core.clj:5425)
at user$eval7.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:6511)
at clojure.lang.Compiler.eval(Compiler.java:6501)
at clojure.lang.Compiler.eval(Compiler.java:6477)
at clojure.core$eval.invoke(core.clj:2797)
at clojure.main$eval_opt.invoke(main.clj:297)
at clojure.main$initialize.invoke(main.clj:316)
at clojure.main$null_opt.invoke(main.clj:349)
at clojure.main$main.doInvoke(main.clj:427)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:419)
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.Var.applyTo(Var.java:532)
at clojure.main.main(main.java:37)
Compilation failed: Subprocess failed
运行后续uberjar
虽然成功创建了jar:
Created ....\lein-check-0.1.0-SNAPSHOT.jar
Including lein-check-0.1.0-SNAPSHOT.jar
Including clojure-1.4.0.jar
Created ....\lein-check-0.1.0-SNAPSHOT-standalone.jar
uberjar有时会在完成后运行main吗?它应该这样做吗?我不太确定这是一个用户错误,一个
lein
错误还是一个clojure错误。问题就在眼前
:main "lein-check.core"
应该是
:main lein-check.core
您使用的是字符串而不是符号 结果显示,
:main
是一个符号,而不是字符串。更新后,运行lein-uberjar
可以正常工作
特别是这一行:
:主“lein check.core”
改为:
:main'lein check.core
对——我想与我的答案相同,只是:main有一个带引号的符号,它们似乎都起作用。