Did you do this step in the deploy your webapp section
- and also add :main my-webapp.handler
If this doesn't help then could you post the entire project.clj file so we can look for other problems?
سؤال
In this tutorial it says
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
I run it from its own directory ~/myapp/target/
but I get an error:
target $ java -jar my-webapp-0.1.0-standalone.jar
no main manifest attribute, in my-webapp-0.1.0-standalone.jar
-main
function is already in 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})))
What am I doing wrong?
EDIT
I am adding my 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"] ]}})
and 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})))
المحلول
Did you do this step in the deploy your webapp section
If this doesn't help then could you post the entire project.clj file so we can look for other problems?