在 this tutorial它说
Now create an uberjar of your webapp (
via lein uberjar
), copy it (target/my-webapp-0.1.0-standalone.jar
) to wherever you like, and run it in the usual way:
java -jar my-webapp-0.1.0-standalone.jar 8080
我从它自己的目录~/myapp/target/
运行它,但收到错误:
target $ java -jar my-webapp-0.1.0-standalone.jar
no main manifest attribute, in 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})))
最佳答案
您是否在deploy your webapp section中执行了这一步?
- 并添加:main my-webapp.handler
如果这没有帮助,那么您可以发布整个project.clj 文件以便我们查找其他问题吗?
关于java - 我在哪个目录运行 java -jar my-webapp-0.1.0-standalone.jar?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20768093/