|
| 1 | +## _Clojure Programming_, Chapter 17 |
| 2 | + |
| 3 | +### Developing Clojure web applications with Maven and Jetty |
| 4 | + |
| 5 | +This project contains a simple Clojure web application that can be |
| 6 | +started and reloaded using Maven and Jetty via the maven-jetty-plugin. |
| 7 | + |
| 8 | +#### Running |
| 9 | + |
| 10 | +In a terminal: |
| 11 | + |
| 12 | +``` |
| 13 | +$ mvn jetty:run |
| 14 | +``` |
| 15 | + |
| 16 | +(…or, if you're using Eclipse or another IDE with "built |
| 17 | +in" Maven support, you can run the `jetty:run` goal in it…) |
| 18 | + |
| 19 | +This will start the Jetty server on port 8080, running the Clojure |
| 20 | +webapp. |
| 21 | + |
| 22 | +You can restart the Jetty server by hitting return in the terminal. It |
| 23 | +is possible to use this mechanism to reload the Clojure application |
| 24 | +after making changes, etc., but a far more flexible and efficient |
| 25 | +approach to interactive development would be to either: |
| 26 | + |
| 27 | +* include a REPL server (either |
| 28 | + [nREPL](http://github.com/clojure/tools.nrepl) or |
| 29 | +[swank](https://github.com/technomancy/swank-clojure)) in your webapp, |
| 30 | +and connect to it from your development environment (e.g. |
| 31 | +[Counterclockwise / Eclipse](http://code.google.com/p/counterclockwise/) |
| 32 | +or |
| 33 | +[Emacs](http://dev.clojure.org/display/doc/Getting+Started+with+Emacs) |
| 34 | +or [vim](http://dev.clojure.org/display/doc/Getting+Started+with+Vim) or |
| 35 | +your other favorite editor/IDE that provides quality Clojure REPL |
| 36 | +support). From there, you can load new code into the running webapp |
| 37 | +with abandon. |
| 38 | +* start the Jetty server from a REPL using the ring-jetty-adapter, to |
| 39 | + which you can provide the top-level var of your webapp. Of course, |
| 40 | +since you're using a REPL, and new code you load will be utilized |
| 41 | +immediately. |
0 commit comments