Brand new Luminus app giving Error: Could not find or load main class clojure.main

Brand new Luminus app giving Error: Could not find or load main class clojure.main

我刚刚通过 运行ning 创建了一个 Luminus 应用程序:

lein new luminus foobar

当我尝试 运行 与工头这样时:

foreman start

文档描述的方式,我得到这个错误:

Error: Could not find or load main class clojure.main

这也是我从 Heroku 得到的相同错误。模板创建的 Procfile 包含以下内容:

web: java $JVM_OPTS -cp target/foobar.jar clojure.main -m foobar.core

这是怎么回事,我该如何解决?

我的最佳猜测是您需要使用命令 lein uberjar 构建项目。此序列有效:

$ lein new luminus foobar
Retrieving ...
Generating a Luminus project.

$ cd foobar
$ lein uberjar
Retrieving ...
Compiling foobar.session
Compiling foobar.layout
Compiling foobar.handler
Compiling foobar.routes.home
Compiling foobar.core
Compiling foobar.middleware
Created /home/ba/foobar/target/foobar-0.1.0-SNAPSHOT.jar
Created /home/ba/foobar/target/foobar.jar

$ cat Procfile 
web: java $JVM_OPTS -cp target/foobar.jar clojure.main -m foobar.core

$ java $JVM_OPTS -cp target/foobar.jar clojure.main -m foobar.core
2015-Jun-22 06:30:42 -0400 ba INFO [foobar.handler] - 
-=[ foobar started successfully nil ]=-
2015-06-22 06:30:42.998:INFO:oejs.Server:jetty-7.x.y-SNAPSHOT
2015-06-22 06:30:43.028:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:3000

关于 Luminus 和 Procfile, 参见 this diff

已在上游修复,但您可以通过更改您的 Procfile 在您的应用中修复它:

web: java $JVM_OPTS -cp target/foobar.jar clojure.main -m foobar.core

至:

web: java $JVM_OPTS -cp target/uberjar/foobar.jar clojure.main -m foobar.core