如何通过逆时针(或la clojure)运行/调试compojure web应用程序

lob*_*ism 7 clojure compojure counterclockwise la-clojure

我正在尝试用compojure编写我的第一个Web应用程序.我正在使用ccw,而且我File-New-Project, Clojure Project使用"compojure"leiningen模板.最终看起来像project.clj

(defproject asdf "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :dependencies [[org.clojure/clojure "1.4.0"]
                 [compojure "1.1.5"]]
  :plugins [[lein-ring "0.8.2"]]
  :ring {:handler asdf.handler/app}
  :profiles
  {:dev {:dependencies [[ring-mock "0.1.3"]]}})
Run Code Online (Sandbox Code Playgroud)

src/asdf/handler.clj看起来像

(ns asdf.handler
  (:use compojure.core)
  (:require [compojure.handler :as handler]
            [compojure.route :as route]))

(defroutes app-routes
  (GET "/" [] "Hello World")
  (route/not-found "Not Found"))

(def app
  (handler/site app-routes))
Run Code Online (Sandbox Code Playgroud)

我发现我可以从命令行运行它lein ring server,但我不知道如何从eclipse运行它.我当然希望不仅能够运行它,还能调试它并设置断点等.在eclipse中有没有办法做到这一点?或者,如果没有,IntelliJ/La-Clojure怎么样?(我现在有点害怕emacs,但也许如果它超级简单我会尝试一下).

或者,这不是一个compojure应用程序的典型开发过程吗?(如果不是,那是什么?只是跑步lein ring server并祈祷?)

如果它有所作为,这是在Win7上.

Lau*_*tit 5

这是一个在开发Ring应用程序时非常适合我的配方:

  • 确保为您的项目配置了正确的leiningen支持(如果有疑问,请执行一次):
    • 在包资源管理器中,选择项目,然后调用上下文命令 Leiningen > Reset configuration
    • 然后还调用该Leiningen > Update dependencies命令
    • 您应该Leiningen Dependencies在项目中看到一个虚拟节点,引用项目的直接和传递依赖项
  • 选择asdf.handler文件,然后右键单击Debug as > Clojure Application
  • asdf.handler在编辑器中打开命名空间
  • 随着光标目前还停留在编辑器中键入Ctrl+Alt+N跳转到REPL和REPL目前的命名空间切换到asdf.handler在同一时间
  • 键入(app)+ Enter(或者Ctrl+Enter如果光标不在行尾)启动应用程序

您现在可以在编辑器和REPL之间导航.

请注意,未来版本的Counterclockwise将与Leiningen 2进行更多集成,但就目前情况而言,开发ring应用程序的本质使得如上所述的引导程序并不那么痛苦,恕我直言