Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can run Compojure/Ring apps on IntelliJ IDEA and La Clojure with the following steps:</p> <ol> <li>Generate <code>pom.xml</code> from leiningen's <code>project.clj</code> using <code>lein pom</code> command.</li> <li>Import maven project with IntelliJ IDEA as usual. You might want to make sure that you have Clojure jar in classpath.</li> <li>Once the project is loaded, you can start Clojure REPL using Tools -> Start Clojure Console.</li> <li>To load a Clojure file to REPL, select Tools -> Clojure REPL -> Load file to REPL.</li> </ol> <p>After that, to start a Ring app you can just load a Clojure file that invokes <code>ring.adapter.jetty/run-jetty</code>. </p> <p>The code to run a simple route on <code>http://localhost:4004/</code> would look like this:</p> <pre><code>(require 'compojure.core) (require 'ring.adapter.jetty) (ring.adapter.jetty/run-jetty (compojure.core/routes (compojure.core/ANY "/" [] "Hello world!")) {:port 4004 :join? false}) </code></pre> <p><code>:join?</code> option is important, if it would be set to true (the default), the REPL would not accept more commands. Your routes will usually be more complex and <code>compojure.core/defroutes</code> or other means should be used.</p> <p>You can put such file in <code>test</code> path, so it wouldn't be loaded when running the project outside of IDEA. If Clojure facet is not added to your module, you can add it in File -> Project Structure -> Modules.</p> <p>A complete sample (with jetty reloading) is available here: <a href="https://github.com/tlipski/ganelon-demo" rel="nofollow">https://github.com/tlipski/ganelon-demo</a> - development is done with IDEA and real site runs on Heroku: <a href="http://ganelon.herokuapp.com" rel="nofollow">http://ganelon.herokuapp.com</a>.</p> <p>Debugging Clojure apps run with the technique above is possible as well - you just have to:</p> <ol> <li>Create Remote debugging Run profile in IntelliJ IDEA</li> <li>Add apropriate JVM options from a profile above (e.g. <code>agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005</code>) to REPL settings in File -> Project Structure -> Modules -> [your module] -> Clojure facet -> JVM Arguments field.</li> <li>Start REPL with Tools -> Start Clojure Console.</li> <li>Start Remote debugging profile.</li> </ol> <p>After that, you can add breakpoints, inspect variables, etc. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload