I'm trying to write my first web app in compojure. I'm using ccw, and I File-New-Project, Clojure Project
and use the "compojure" leiningen template. End up with project.clj looking like
(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"]]}})
src/asdf/handler.clj looks like
(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))
I found I can run this using lein ring server
from the command line, but I'm not sure how to run this from eclipse. I'm of course hoping to be able not only to run it, but also to debug it and set breakpoints and such. Is there a way to do this in eclipse? Or, if not, how about IntelliJ/La-Clojure? (I'm a bit afraid of emacs, for now, but maybe if it's super-simple I'd give it a try).
Or, is this just not the typical development process for a compojure app? (If not, what is? Just run lein ring server
and pray?)
If it makes a difference this is on Win7.
Here's a recipe that's work great for me while developing Ring applications:
Leiningen > Reset configuration
Leiningen > Update dependencies
commandLeiningen Dependencies
virtual node in your project, referencing the direct and transitive dependencies of your projectasdf.handler
file, right click and then Debug as > Clojure Application
asdf.handler
namespace in an editorCtrl+Alt+N
to jump to the REPL and switch the REPL's current namespace to asdf.handler
at the same time(app)
+ Enter
(or Ctrl+Enter
if your cursor is not at the end of the line)You can now navigate between the editors and the REPL.
Ctrl+Enter
Ctrl+Enter
without a selection, the whole 'top level expression' (e.g. a defn) will be sent to the REPLCtrl+Alt+S
Note that a future version of Counterclockwise will integrate a little bit more with Leiningen 2, but as it currently stands, the very nature of developing ring
applications make it not so painful to bootstrap things as described above, IMHO