使用Leiningen部署Clojure应用程序 [英] Deploying Clojure apps with Leiningen
本文介绍了使用Leiningen部署Clojure应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的project.clj文件到目前为止:
(defproject raj0.0.1-SNAPSHOT
:descriptionFIXME:write description
:dependencies [[org.clojure / clojure1.3.0]]
:keep-non-project-classes true
:main raj。核心)
和我的core.clj文件:
(ns raj.core
(:use raj.core))
(defn -main [& args]
(printlnHello World !!!))
raj.core
显示Hello World消息就好了。接下来我尝试 lein uberjar
并获取
编译raj.core
编译成功。
创建的C:\Users\bobjones\IdeaProjects\raj / raj-0.0.1-SNAPSHOT.jar
包括raj-0.0.1-SNAPSHOT.jar
包括clojure- 1.3.0.jar
创建的C:\Users\bobjones\IdeaProjects\raj / raj-0.0.1-SNAPSHOT-standalone.jar
到目前为止,一切似乎都进展顺利,所以我尝试 java -jar raj-0.0.1-SNAPSHOT-standalone.jar
,我收到
错误:找不到或加载主类raj.core
这里会出现什么错误?
解决方案您需要向 raj.core
命名空间添加:gen-class
/ p>
(ns raj.core
(:use raj.core)
(:gen-class))
This is my project.clj file so far:
(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)
And my core.clj file:
(ns raj.core
(:use raj.core))
(defn -main [& args]
(println "Hello World!!!"))
lein run -m raj.core
displays the Hello World message just fine. So next I try lein uberjar
and get
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
Everything seems to be going well so far, so I try java -jar raj-0.0.1-SNAPSHOT-standalone.jar
, and I receive
Error: Could not find or load main class raj.core
What would I be doing wrong here?
解决方案 You need to add a :gen-class
declaration to the raj.core
namespace:
(ns raj.core
(:use raj.core)
(:gen-class))
这篇关于使用Leiningen部署Clojure应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文