【问题标题】:How to start a new Clojure lein project using a template behind corporate proxy or maven mirror如何使用公司代理或 maven 镜像后面的模板启动新的 Clojure lein 项目
【发布时间】:2017-09-30 04:43:29
【问题描述】:

我正在尝试在公司代理或本地 maven 镜像后面使用 lein 新模板构建,但失败:

C:\development\clojure> lein new luminus guestbook +h2
Failed to resolve version for luminus:lein-template:jar:RELEASE: Could not find metadata luminus:lein-template/maven-metadata.xml in local (C:\Users\username\.m2\repository)
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.
Could not find template luminus on the classpath.

将以下几行放在profiles.clj 中似乎没有效果:

:mirrors {"central" {:name "central" 
  :url "http://server.company_name.com:8080/artifactory/maven.central/"}} 

环境变量(大写/小写似乎也没有影响):

HTTP_PROXY=http://username:password@proxy.company_name.com:8080
HTTPS_PROXY=https://username:password@proxy.company_name.com:8080
HTTP_NO_PROXY=*.company_name.com
HTTP_CLIENT=wget --no-check-certificate -O

注意:我还指定了没有用户名和密码的 HTTP/S 代理,这会导致同样的失败。

我也无法确定如何生成调试级别日志记录以帮助排除故障。

Java 1.8.0_144 Java HotSpot(TM) 64 位服务器虚拟机上的 Leiningen 2.7.0

Clojure 1.8.0

【问题讨论】:

    标签: clojure proxy leiningen


    【解决方案1】:

    我更新了包含 Maven 配置设置的文件 ~.m2/settings.xml,如下所示:

    <settings ...>
      ...
      <profiles>
        ...
        <profile>
          <id>alwaysActive</id>
          <repositories>
            ...
            <repository>
              <id>clojars</id>
              <name>Repository for Clojure builds</name>
                        <snapshots> 
                            <enabled>false</enabled> 
                        </snapshots> 
              <url>https://clojars.org/repo</url>
              <layout>default</layout>
            </repository>
          </repositories>
        </profile>
    
      </profiles>
    
      <activeProfiles>
        <activeProfile>alwaysActiveProfile</activeProfile>
      </activeProfiles>
    
    </settings>
    

    这个版本的 Lein 似乎添加了 Clojars 存储库搜索路径来解决依赖关系,而不是项目模板。通过进行此 Maven 配置更改,它会导致 Lein 调用的 Maven 自动搜索附加的 Clojars 存储库。这似乎是一种不一致的行为,有望在未来的 Lein 版本中得到解决。

    【讨论】:

      【解决方案2】:

      我在 clojars.org 找到了 luminus:lein-template:2.9.11.90 工件,并使用 Maven 手动将其检索到我的本地 M2 存储库中。

      C:\development\clojure> mvn dependency:get -DremoteRepositories=https://clojars.org/repo -Dartifact=luminus:lein-template:2.9.11.90
      [INFO] Scanning for projects...
      [INFO]
      [INFO] ------------------------------------------------------------------------
      [INFO] Building Maven Stub Project (No POM) 1
      [INFO] ------------------------------------------------------------------------
      [INFO]
      [INFO] --- maven-dependency-plugin:2.8:get (default-cli) @ standalone-pom ---
      [INFO] Resolving luminus:lein-template:jar:2.9.11.90 with transitive dependencies
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD SUCCESS
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 2.160 s
      [INFO] Finished at: 2017-09-30T16:58:11-04:00
      [INFO] Final Memory: 11M/216M
      [INFO] ------------------------------------------------------------------------
      

      一旦这个工件在本地可用,我就能够成功地使用模板来创建项目:

      C:\development\clojure> lein new luminus guestbook +h2
      Generating a Luminus project.
      

      完成并移动到新项目目录后,我可以成功下载依赖项并使用“lein run”运行项目。

      这并不能解决 lein 在从模板创建项目时使用代理配置的问题,但确实提供了一种解决方法。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-10-28
        • 1970-01-01
        • 2023-03-25
        • 1970-01-01
        • 1970-01-01
        • 2021-05-30
        • 2012-08-05
        相关资源
        最近更新 更多