【问题标题】:Unable to pull dependencies from central/clojars无法从中心/clojars 中提取依赖项
【发布时间】:2018-02-14 11:27:58
【问题描述】:

我的 project.clj 文件看起来像 -

(defproject somename "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.9.0"]
                 [org.apache.kafka/kafka-clients "0.11.0.2"]]
  :main somename.core
  :target-path "target/%s"
  :profiles {:dev {:dependencies [[lein-light-nrepl "0.3.3"]
                                  [enlive "1.1.6"]
                                  [cheshire "5.8.0"]
                                  [criterium "0.4.4"]]}}
  :repl-options {:nrepl-middleware [lighttable.nrepl.handler/lighttable-ops]})

lein repl 在项目目录之外工作正常。

$ lein repl
nREPL server started on port 34420 on host 127.0.0.1 - 
nrepl://127.0.0.1:34420
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.8.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_161-b12
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
    Source: (source function-name-here)
    Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
    Results: Stored in vars *1, *2, *3, an exception in *e

user=> 

但是,对于这个项目,当我在做lein deps 时,它无法拉取依赖项。 我收到一个错误,例如-

Could not transfer artifact org.apache.kafka:kafka-
clients:pom:0.11.0.2 from/to central (https://repo1.maven.org/maven2/): Connect to  [localhost/127.0.0.1] failed: Connection refused (Connection refused)
This could be due to a typo in :dependencies or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.

lein和java版本如下-

$ lein version
Leiningen 2.7.1 on Java 1.8.0_161 Java HotSpot(TM) 64-Bit Server VM

$ java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

请帮帮我。

【问题讨论】:

  • 我不确定 lein 是否使用 $HOME/.m2/settings.xml - 也许你在那里定义了一些 localhost 镜像?
  • @PiotrekBzdyl 我的.m2 目录中没有这样的文件。
  • http代理环境变量呢?

标签: java clojure localhost leiningen


【解决方案1】:

我之前也遇到过同样的问题。我认为这是因为一些硬编码的 repo url 使用 HTTP 方案而不是 HTTPS。 把它放在你的 project.clj 中应该会有所帮助:

:repositories [["jitpack" "https://jitpack.io"]
               ["central" "https://repo1.maven.org/maven2"]
               ["clojure" "https://build.clojure.org/releases"]
               ["clojars" "https://clojars.org/repo"]
               ["java.net" "https://download.java.net/maven/2"]
               ["jboss.release" "https://repository.jboss.org/nexus/content/groups/public"]
               ["terracotta-releases" "https://www.terracotta.org/download/reflector/releases"]
               ["terracotta-snapshots" "https://www.terracotta.org/download/reflector/snapshots"]
               ["apache.snapshots" "https://repository.apache.org/snapshots"]]

【讨论】:

    猜你喜欢
    • 2018-02-19
    • 1970-01-01
    • 2013-07-06
    • 1970-01-01
    • 2012-12-18
    • 1970-01-01
    • 2020-07-08
    • 2018-05-10
    • 2019-03-23
    相关资源
    最近更新 更多