The problem is that lein don't know where to locate your -main
function:
First, you shall create .clj
file to run. You can specify it's namespace using ns macro. Then you shall define -main
function in this namespace:
(ns my-website.server
(:require [noir.server :as server]
[noir.core :refer [defpage]]))
(defpage "/welcome" []
"Welcome to Noir!")
(defn -main
[& args]
(server/start 4000))
Then you shall configure your project.clj
:
(defproject my-website "0.1.0-SNAPSHOT"
:description "..."
:dependencies [[org.clojure/clojure "1.4.0"]
[noir "1.2.2"]]
:main my-website.server)
[noir "1.2.2"]
is the latest stable version of noir. It's best to use this one.
Do not forget to place this file into your source directory. Bu default its ./src
dir in your project root. So, if your namespace is called my-website.server
then lein will look for it in ./src/my-website/server.clj
file (or in ./src/my_website/server.clj
, I'm not sure).
Now lein run
will cause lein to enter namespace my-website.server
and then to run (-main)
function.
See sample lein project for more info.
You can also generate project.clj
for your noir project using lein noir template.