Switch branches/tags
Nothing to show
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Clojure Programming, Chapter 17

Packaging and running Clojure web applications with Maven and Jetty

This project contains a simple Clojure web application that can be started and reloaded using Maven and Jetty via the maven-jetty-plugin.


Maven makes it easy to package up a Clojure webapp up as a standard war file, which can then be deployed directly to any standard Java web app container, or to any of the cloud platforms that support Java/war deployment.

In a terminal:

$ mvn package

This will produce the war file in the target subdirectory.


In a terminal:

$ mvn jetty:run

(…or, if you're using Eclipse or another IDE with "built in" Maven support, you can run the jetty:run goal in it…)

This will start the Jetty server on port 8080, running the Clojure webapp.

You can restart the Jetty server by hitting return in the terminal. It is possible to use this mechanism to reload the Clojure application after making changes, etc., but a far more flexible and efficient approach to interactive development would be to either:

  • include a REPL server (either nREPL or swank) in your webapp, and connect to it from your development environment (e.g. Counterclockwise / Eclipse or Emacs or vim or your other favorite editor/IDE that provides quality Clojure REPL support). From there, you can load new code into the running webapp with abandon.
  • start the Jetty server from a REPL using the ring-jetty-adapter, to which you can provide the top-level var of your webapp. Of course, since you're using a REPL, and new code you load will be utilized immediately.