【问题标题】:JHipster configure maven wrapper proxyJHipster 配置 maven 包装代理
【发布时间】:2017-05-02 10:44:57
【问题描述】:

根据https://jhipster.github.io/configuring-a-corporate-proxy/,我在 /.m2/settings.xml 中设置了我的代理设置,如下所示:

  <proxies>
    <proxy>
      <id>myId</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>myDomain\myUsername</username>
      <password>myPassword</password>
      <host>myHost</host>
      <port>myPort</port>
    </proxy>
  </proxies>

但不知何故,当我尝试 mvnw 项目时它不起作用,它给了我:

Exception in thread "main" java.net.ConnectException: Connection refused: connect

我在将以下参数传递给 MAVEN_OPTS 时设法让它工作,但我想只使用 settings.xml 文件。

set MAVEN_OPTS=-Dhttps.proxyHost=myHost -Dhttps.proxyPort=myPort -Dhttps.proxyUser=myDomain\myUsername -Dhttps.proxyPassword=myPassword

有人可以帮忙吗?

提前致谢。

【问题讨论】:

  • 在 MAVEN_OPTS 中使用 https 时在 settings.xml 中设置 http 是否正常?
  • Maven 应该使用 http 处理 https。无论如何我试图把https,同样的错误。

标签: maven https proxy jhipster


【解决方案1】:

Maven Wrapper 似乎不使用 Maven 设置中的代理变量。 Downloader 没有配置任何代理,因此这意味着必须使用 Java 系统属性。对于身份验证,它只查找系统属性http.proxyUseruses it

设置 MAVEN_OPTS(正如您提到的以及 here)有效:

set MAVEN_OPTS="-Dhttp.proxyHost=proxyhost -Dhttp.proxyPort=8080 -Dhttps.proxyHost=proxyhost -Dhttps.proxyPort=8080"

export MAVEN_OPTS="-Dhttp.proxyHost=proxyhost -Dhttp.proxyPort=8080 -Dhttps.proxyHost=proxyhost -Dhttps.proxyPort=8080"

mvnw 脚本还从项目路径中拉入一个文件.mvn/jvm.config,其中可以包含以下属性:

-Dhttp.proxyHost=host 
-Dhttp.proxyPort=port 
-Dhttps.proxyHost=host 
-Dhttps.proxyPort=port 
-Dhttp.proxyUser=username 
-Dhttp.proxyPassword=password

我已经打开了一个拉取请求 (#446) 以将此信息添加到 JHipster 文档中。

【讨论】:

  • 非常感谢! jvm.config 文件为我解决了这个问题。
  • 值需要引号,应该是export MAVEN_OPTS="-Dhttp.proxyHost=proxyhost -Dhttp.proxyPort=8080 -Dhttps.proxyHost=proxyhost -Dhttps.proxyPort=8080"
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-08-09
  • 2017-02-05
  • 2017-05-21
  • 2012-02-15
相关资源
最近更新 更多