在本教程中,它说
现在创建一个 uberjar 的 webapp (
via lein uberjar
),复制它 (target/my-webapp-0.1.0-standalone.jar
) 到任何你喜欢的地方,以及 以通常的方式运行它:
java -jar my-webapp-0.1.0-standalone.jar 8080
我从它自己的目录运行它~/myapp/target/
但出现错误:
Target $ Java -jar my-webapp-0.1.0-standalone.jar
在 my-webapp-0.1.0-standalone 中没有主清单属性.jar
-main
函数已经在handler.clj中:
(ns my-webapp.handler
(:require [my-webapp.views :as views]
[compojure.core :as cc]
[compojure.handler :as handler]
[compojure.route :as route]
[ring.adapter.jetty :as jetty]
(:gen-class)))
(cc/defroutes app-routes
(cc/GET "/"
[]
(views/home-page))
(cc/GET "/add-location"
[]
(views/add-location-page))
(cc/POST "/add-location"
{params :params}
(views/add-location-results-page params))
(cc/GET "/location/:loc-id"
[loc-id]
(views/location-page loc-id))
(cc/GET "/all-locations"
[]
(views/all-locations-page))
(route/resources "/")
(route/not-found "Not Found"))
(def app
(handler/site app-routes))
(defn -main
[& [port]]
(let [port (Integer. (or port
(System/getenv "PORT")
5000))]
(jetty/run-jetty #'app {:port port
:join? false})))
我做错了什么?
编辑
我正在添加我的project.clj
:
(defproject my-webapp "0.1.0"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:dependencies [[org.clojure/clojure "1.5.1"]
[hiccup "1.0.2"]
[org.clojure/java.jdbc "0.2.3"]
[com.h2database/h2 "1.3.170"]
[compojure "1.1.6"]
[ring/ring-jetty-adapter "1.2.1"]]
:main my-webapp.handler
:plugins [[lein-ring "0.8.8"]]
:ring {:handler my-webapp.handler/app}
:profiles
{:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
[ring-mock "0.1.5"]
[org.clojure/java.jdbc "0.0.4"] ]}})
和handler.clj
(ns my-webapp.handler
(:require [my-webapp.views :as views]
[compojure.core :as cc]
[compojure.handler :as handler]
[compojure.route :as route]
[ring.adapter.jetty :as jetty])
(:gen-class))
(cc/defroutes app-routes
(cc/GET "/"
[]
(views/home-page))
(cc/GET "/add-location"
[]
(views/add-location-page))
(cc/POST "/add-location"
{params :params}
(views/add-location-results-page params))
(cc/GET "/location/:loc-id"
[loc-id]
(views/location-page loc-id))
(cc/GET "/all-locations"
[]
(views/all-locations-page))
(route/resources "/")
(route/not-found "Not Found"))
(def app
(handler/site app-routes))
(defn -main
[& [port]]
(let [port (Integer. (or port
(System/getenv "PORT")
5000))]
(jetty/run-jetty #'app {:port port
:join? false})))
您是否在部署 Web 应用部分中执行了此步骤
- 并添加:main my-webapp.handler
如果这没有帮助,那么您能否发布整个 project.clj 文件,以便我们查找其他问题?