Compojure 应用程序在本地运行,但在部署到 Heroku 时找不到 main class lein
Compojure app runs locally, but cannot find main class lein when deployed to Heroku
我有一个用 ring 和 compojure 构建的小型 Clojure webapp。尽管 webapp 在我的笔记本电脑上本地运行 find,但当我推送到 Heroku 时,该应用程序崩溃了。日志中的具体错误是
Starting process with command `java $JVM_OPTS lein ring server-headless 3000`
app[web.1]: Error: Could not find or load main class lein
app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx384m -Djava.rmi.server.useCodebaseOnly=true
heroku[web.1]: State changed from starting to crashed
我的 project.clj
长得像
(defproject hn-clj "0.1.1"
:description "foo"
:url "http://foo"
:min-lein-version "2.0.0"
:dependencies [[org.clojure/clojure "1.6.0"]
[compojure "1.3.1"]
[ring/ring-defaults "0.1.2"]
[clj-http-lite "0.2.0"]
[cheshire "5.4.0"]
[hiccup "1.0.5"]]
:plugins [[lein-ring "0.8.13"]]
:ring {:handler hn-clj.core.handler/app}
:profiles
{:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
[ring-mock "0.1.5"]]}}
)
应用程序的入口点在 src/core/handler.clj
(ns hn-clj.core.handler
(:require [compojure.core :refer :all]
[compojure.route :as route]
[compojure.handler :as handler]
[ring.middleware.defaults :refer [wrap-defaults site-defaults]]
[hn-clj.core.controllers.story :as story]
[hn-clj.core.controllers.users :as users]
))
(defroutes app-routes
(GET "/" [limit] (story/index limit))
(GET "/stories/:id" [id] (story/show-story id))
(GET "/users/:username" [username] (users/show username)))
(def app
(wrap-defaults app-routes site-defaults))
应用程序在本地使用 lein ring server-headless 3000
运行查找,在我的 Procfile
中我已经输入
web: java $JVM_OPTS lein ring server-headless 3000
虽然我没有创建main-
函数,但这并没有禁止应用程序在本地运行,我不明白为什么应用程序部署到Heroku时不会运行。我应该如何重构 handler.clj
或 Procfile
?
我有一个用 ring 和 compojure 构建的小型 Clojure webapp。尽管 webapp 在我的笔记本电脑上本地运行 find,但当我推送到 Heroku 时,该应用程序崩溃了。日志中的具体错误是
Starting process with command `java $JVM_OPTS lein ring server-headless 3000`
app[web.1]: Error: Could not find or load main class lein
app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx384m -Djava.rmi.server.useCodebaseOnly=true
heroku[web.1]: State changed from starting to crashed
我的 project.clj
长得像
(defproject hn-clj "0.1.1"
:description "foo"
:url "http://foo"
:min-lein-version "2.0.0"
:dependencies [[org.clojure/clojure "1.6.0"]
[compojure "1.3.1"]
[ring/ring-defaults "0.1.2"]
[clj-http-lite "0.2.0"]
[cheshire "5.4.0"]
[hiccup "1.0.5"]]
:plugins [[lein-ring "0.8.13"]]
:ring {:handler hn-clj.core.handler/app}
:profiles
{:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
[ring-mock "0.1.5"]]}}
)
应用程序的入口点在 src/core/handler.clj
(ns hn-clj.core.handler
(:require [compojure.core :refer :all]
[compojure.route :as route]
[compojure.handler :as handler]
[ring.middleware.defaults :refer [wrap-defaults site-defaults]]
[hn-clj.core.controllers.story :as story]
[hn-clj.core.controllers.users :as users]
))
(defroutes app-routes
(GET "/" [limit] (story/index limit))
(GET "/stories/:id" [id] (story/show-story id))
(GET "/users/:username" [username] (users/show username)))
(def app
(wrap-defaults app-routes site-defaults))
应用程序在本地使用 lein ring server-headless 3000
运行查找,在我的 Procfile
中我已经输入
web: java $JVM_OPTS lein ring server-headless 3000
虽然我没有创建main-
函数,但这并没有禁止应用程序在本地运行,我不明白为什么应用程序部署到Heroku时不会运行。我应该如何重构 handler.clj
或 Procfile
?