Tôi đang theo dõi cùng với this example để tạo một dịch vụ web đơn giản trong Clojure bằng cách sử dụng chuông và cầu nối.Làm thế nào để chạy Ví dụ Jetty với Ring ở Clojure
Tôi có điều này trong project.clj tôi:
(defproject ws-example "0.0.1"
:description "REST datastore interface."
:dependencies
[[org.clojure/clojure "1.5.1"]
[ring/ring-jetty-adapter "0.2.5"]
[ring-json-params "0.1.0"]
[compojure "0.4.0"]
[clj-json "0.5.3"]]
:dev-dependencies
[[lein-run "1.0.0-SNAPSHOT"]])
này trong kịch bản/run.clj
(use 'ring.adapter.jetty)
(require '[ws-example.web :as web])
(run-jetty #'web/app {:port 8080})
Và điều này trong src/ws_example/web.clj
(ns ws-example.web
(:use compojure.core)
(:use ring.middleware.json-params)
(:require [clj-json.core :as json]))
(defn json-response [data & [status]]
{:status (or status 200)
:headers {"Content-Type" "application/json"}
:body (json/generate-string data)})
(defroutes handler
(GET "/" []
(json-response {"hello" "world"}))
(PUT "/" [name]
(json-response {"hello" name})))
(def app
(-> handler
wrap-json-params))
Tuy nhiên, khi tôi thực hiện:
lein run script/run.clj
tôi nhận được lỗi này:
No :main namespace specified in project.clj.
Tại sao tôi nhận này và làm thế nào để sửa chữa nó?
Hướng dẫn bạn liên kết với sử dụng Leiningen 1.x - bạn có lẽ nên sử dụng lein2. – Alex
Thật tuyệt vời nếu tôi có thể tìm thấy một hướng dẫn mà chỉ làm việc kể từ khi tôi đang học. Bất kỳ đề xuất? Tôi muốn tạo một dịch vụ web ở Clojure –