Compojure Demystified with an example – Part 2
In part 1 I introduced the address book application that we are going to build.
In this part we will setup our skeleton project with compojure.
1) Install Leiningen
http://github.com/technomancy/leiningen/blob/master/README.md
2) Create a new project using Leiningen
lein new address_book
3) Add Compojure to our project:
a) Edit project.clj
(defproject address_book "1.0.0-SNAPSHOT"
:description "Address Book"
:dependencies [[org.clojure/clojure "1.1.0"]
[org.clojure/clojure-contrib "1.1.0"]
[compojure "0.4.1"]
[ring/ring-jetty-adapter "0.2.3"]])
b) Install dependencies
lein deps
This should install all dependencies of compojure
c) Test whether our setup is working
Edit src/address_book/core.clj
(ns address_book.core
(:use [compojure.core]
[ring.adapter.jetty])
(:require [compojure.route :as route]))
(defroutes example
(GET "/" [] "My Address Book!")
(route/not-found "Page not found"))
(run-jetty example {:port 8080})
Run the server
lein repl src/address_book/core.clj
Goto http://localhost:8080 and you should see “My Address Book!”
In next part we will start implementing our functionalities.

The repl line doesn’t work any more :
address_book% lein repl src/address_book/core.clj
Wrong number of arguments to repl task.
Expected ([] [project])
It looks like the best way to achieve that is to add:
:repl-init address_book.core
to the project.clj file – then you can run “lein repl”.
William Roe
July 17, 2011 at 8:36 am
I think the “lein repl…” command was supposed to be “lein run …” which would require a “:main address_book.core” entry into the project.clj
Also, the “current” (at the time of writing) working set of versions for the libraries appearing above in the project.clj file are:
:dependencies [[org.clojure/clojure "1.5.0"]
[org.clojure/clojure-contrib "1.2.0"]
[compojure "1.1.5"]
[ring/ring-jetty-adapter "1.1.0"]]
andee_marks
May 27, 2013 at 11:47 pm