Deploy Compojure Application as Tomcat Webapp
Contents
There are many basic startup code examples for Compojure on the web, but I don’t see any kind of deployment tutorial. Here are some basic collections if you want to use Clojure to start a web development.
-
First, clone the code of compojure-example, and run it with the instructions on the page. If you can run it successfully by command
lein ring server
, then you can proceed to next step.
-
Try to develop your web site with the lein ring server. This is the best way to develop Clojure web application for it can refresh your code automatically.
-
Here comes the final step to deploy Clojure code to web server to provide official service for other people. First, package all resources such as code, css, html template files to war file:
lein ring uberwar
Then config your Tomcat according to manual and deploy the war file with http://localhost:8080/manager. There is a “WAR file to deploy” option on the manager page. It is the key point of deploying Clojure service to Tomcat. You can just think it is a Java application and use the normal way to deploy it.
BTW: the Tomcat root folder is something like D:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\ROOT. If you web application can’t load some resource file, please check the relative path for it.
Author Watterry
LastMod 2014-01-17