Build clojure development environment-use idea and Leiningen

Source: Internet
Author: User

Os:mac OS X 10.10

Idea 14.0.2 Community Edition

Installing Leiningen

Follow http://leiningen.org/'s Guide to install Lein

Read Leiningen tutorial Chinese version to learn about Leiningen

If you need to use a proxy, you need to perform

Export Https_proxy=host:port

Export Http_proxy=host:port

(When executing Lein deps, if you also need to use a proxy, export https_proxy and export http_proxy)

Installing La Clojure

Install the idea plugin La Clojure. After the idea, point to the top left corner of IntelliJ idea, choose Preferences, then choose Plugins on the left, click Browse Repositories, search Clojure, download La Clojure.

New Project

Establish Clojure project under the workspace. Enter Lein new Groupid/artifactid. GroupID and Artifactid in the same concept as Maven.

For example, if I enter Lein new Hs.clojure/learn, I will build a clojure project according to the template.

Import idea

This project directly into idea will not be recognized correctly, so you need to execute the Lein pom in the Learn directory and generate the corresponding POM.

Then import project in idea, select Import project from external model, and then point to Maven, all the way down.

Configure the main function

In the open Idea Project, open the SRC directory with the Learn.clj file in the Hs.clojure package.

There is no main function in this Clojure file, so run is executed in idea and nothing is output.

Change the contents of this file.

(NS Hs.clojure.learn) (Defn-main  [& args]  (println "Hello, world!"))

Then click Run in the top menu of idea, select Edit configurations, select Run main function in the script namespace, click OK.

Execute run "Learn" in the Run menu and the program will print "Hello, world!".

At this point, if you execute Lein run, you will say "No:main namespace specified in Project.clj".

Need to modify PROJECT.CLJ

(Defproject hs.clojure/learn "0.1.0-snapshot"  : Main hs.clojure.learn  :d ependencies [[Org.clojure/clojure] 1.6.0 "])

After saving, execute Lein run, output "Hello, world!"

Build clojure development environment-use idea and Leiningen

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.