Use leiningen to create the first clojure project 2

Source: Internet
Author: User

Add a CLJ-HTTP dependency to the Project 1 project file:

(defproject project1 "0.1.0-SNAPSHOT"  :description "FIXME: write description"  :url "http://example.com/FIXME"  :license {:name "Eclipse Public License"            :url "http://www.eclipse.org/legal/epl-v10.html"}  :dependencies [[org.clojure/clojure "1.4.0"]                 [clj-http "0.6.3"]                 ])

: SRC is not set here, so the default value is actually used, src directory.

Version can refer to the website: https://clojars.org/search? Q = CLJ-HTTP

The clojars.org site is very useful, please remember.

Open the repl session and you will see a bunch of download dependency information:

~/project1$ lein replCould not find artifact clj-http:clj-http:pom:0.6.3 in central (http://repo1.maven.org/maven2)Retrieving clj-http/clj-http/0.6.3/clj-http-0.6.3.pom (4k)    from https://clojars.org/repo/Retrieving org/apache/httpcomponents/httpcore/4.2.3/httpcore-4.2.3.pom (6k)    from http://repo1.maven.org/maven2/Retrieving org/apache/httpcomponents/httpcomponents-core/4.2.3/httpcomponents-core-4.2.3.pom (11k)    from http://repo1.maven.org/maven2/Retrieving org/apache/httpcomponents/project/6/project-6.pom (23k)    from http://repo1.maven.org/maven2/Retrieving org/apache/httpcomponents/httpclient/4.2.2/httpclient-4.2.2.pom (6k)    from http://repo1.maven.org/maven2/Retrieving org/apache/httpcomponents/httpcomponents-client/4.2.2/httpcomponents-client-4.2.2.pom (14k)    from http://repo1.maven.org/maven2/Retrieving org/apache/httpcomponents/httpcore/4.2.2/httpcore-4.2.2.pom (6k)    from http://repo1.maven.org/maven2/Retrieving org/apache/httpcomponents/httpcomponents-core/4.2.2/httpcomponents-core-4.2.2.pom (11k)    from http://repo1.maven.org/maven2/Retrieving commons-codec/commons-codec/1.6/commons-codec-1.6.pom (11k)    from http://repo1.maven.org/maven2/Retrieving org/apache/httpcomponents/httpmime/4.2.2/httpmime-4.2.2.pom (5k)    from http://repo1.maven.org/maven2/Retrieving commons-io/commons-io/2.4/commons-io-2.4.pom (10k)    from http://repo1.maven.org/maven2/Retrieving org/apache/commons/commons-parent/25/commons-parent-25.pom (47k)    from http://repo1.maven.org/maven2/Could not find artifact slingshot:slingshot:pom:0.10.3 in central (http://repo1.maven.org/maven2)Retrieving slingshot/slingshot/0.10.3/slingshot-0.10.3.pom (2k)    from https://clojars.org/repo/Could not find artifact cheshire:cheshire:pom:5.0.1 in central (http://repo1.maven.org/maven2)Retrieving cheshire/cheshire/5.0.1/cheshire-5.0.1.pom (3k)    from https://clojars.org/repo/Retrieving com/fasterxml/jackson/core/jackson-core/2.1.1/jackson-core-2.1.1.pom (6k)    from http://repo1.maven.org/maven2/Retrieving com/fasterxml/oss-parent/4/oss-parent-4.pom (18k)    from http://repo1.maven.org/maven2/Retrieving com/fasterxml/jackson/dataformat/jackson-dataformat-smile/2.1.1/jackson-dataformat-smile-2.1.1.pom (3k)    from http://repo1.maven.org/maven2/Could not find artifact crouton:crouton:pom:0.1.1 in central (http://repo1.maven.org/maven2)Retrieving crouton/crouton/0.1.1/crouton-0.1.1.pom (3k)    from https://clojars.org/repo/Retrieving org/jsoup/jsoup/1.7.1/jsoup-1.7.1.pom (5k)    from http://repo1.maven.org/maven2/Could not find artifact clj-http:clj-http:jar:0.6.3 in central (http://repo1.maven.org/maven2)Retrieving commons-codec/commons-codec/1.6/commons-codec-1.6.jar (227k)    from http://repo1.maven.org/maven2/Retrieving org/apache/httpcomponents/httpmime/4.2.2/httpmime-4.2.2.jar (26k)    from http://repo1.maven.org/maven2/Retrieving org/apache/httpcomponents/httpclient/4.2.2/httpclient-4.2.2.jar (418k)    from http://repo1.maven.org/maven2/Retrieving org/apache/httpcomponents/httpcore/4.2.3/httpcore-4.2.3.jar (222k)    from http://repo1.maven.org/maven2/Retrieving commons-io/commons-io/2.4/commons-io-2.4.jar (181k)    from http://repo1.maven.org/maven2/Could not find artifact slingshot:slingshot:jar:0.10.3 in central (http://repo1.maven.org/maven2)Could not find artifact crouton:crouton:jar:0.1.1 in central (http://repo1.maven.org/maven2)Retrieving org/jsoup/jsoup/1.7.1/jsoup-1.7.1.jar (272k)    from http://repo1.maven.org/maven2/Retrieving slingshot/slingshot/0.10.3/slingshot-0.10.3.jar (8k)    from https://clojars.org/repo/Retrieving crouton/crouton/0.1.1/crouton-0.1.1.jar (3k)    from https://clojars.org/repo/Retrieving clj-http/clj-http/0.6.3/clj-http-0.6.3.jar (19k)    from https://clojars.org/repo/nREPL server started on port 59868REPL-y 0.1.0-beta10Clojure 1.4.0    Exit: Control+D or (exit) or (quit)Commands: (user/help)    Docs: (doc function-name-here)          (find-doc "part-of-name-here")  Source: (source function-name-here)          (user/sourcery function-name-here) Javadoc: (javadoc java-object-or-class-here)Examples from clojuredocs.org: [clojuredocs or cdoc]          (user/clojuredocs name-here)          (user/clojuredocs "ns-here" "name-here")user=>

When you start a repl session, you can find that the dependency of project1 does not exist. It is intelligent to automatically download it. I just don't understand how it is implemented. This question should be put aside first and then solved later.

Then you need to restart the session.

Modify the source code of the Project obtained in the previous article. In the src/project/CORE. CLJ file, change the foo function to main:

(ns project1.core)(defn -main  "I don't do a whole lot."  [& args]  (println "Hello, World!"))

Okay. input the following command in the repl session. Everything is normal:

user=> (require 'project1.core)niluser=> (source project1.core/-main)(defn -main  "I don't do a whole lot."  [& args]  (println "Hello, World!"))niluser=> (project1.core/-main)Hello, World!nil

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.