使用 Leiningen 部署 Clojure 应用程序

2022-09-03 05:23:36

到目前为止,这是我的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

我在这里做错了什么?


答案 1

您需要向命名空间添加一个声明::gen-classraj.core

(ns raj.core
  (:use raj.core)
  (:gen-class))

答案 2

推荐