小编典典

使用Leiningen部署Clojure应用

java

到目前为止,这是我的project.clj文件:

(defproject raj "0.0.1-SNAPSHOT"
  :description "FIXME: write description"
  :dependencies [[org.clojure/clojure "1.3.0"]]
  :keep-non-project-classes true
  :main raj.core)

和我的core.clj文件:

(ns raj.core
  (:use raj.core))

(defn -main [& args]
  (println "Hello World!!!"))

lein run -m raj.core显示Hello World消息就好了。所以下次我尝试lein uberjar并获得

Compiling raj.core
Compilation succeeded.
Created C:\Users\bobjones\IdeaProjects\raj/raj-0.0.1-SNAPSHOT.jar
Including raj-0.0.1-SNAPSHOT.jar
Including clojure-1.3.0.jar
Created C:\Users\bobjones\IdeaProjects\raj/raj-0.0.1-SNAPSHOT-standalone.jar

到目前为止,一切似乎进展顺利,所以我尝试了java -jar raj-0.0.1-SNAPSHOT-standalone.jar,然后我收到了

Error: Could not find or load main class raj.core

我在这里怎么做错了?


阅读 300

收藏
2020-12-03

共1个答案

小编典典

您需要向名称空间添加:gen-class声明raj.core

(ns raj.core
  (:use raj.core)
  (:gen-class))
2020-12-03