简体   繁体   English

JHipster 配置 Maven 包装代理

[英]JHipster configure maven wrapper proxy

According to https://jhipster.github.io/configuring-a-corporate-proxy/ I have set up my proxy settings in /.m2/settings.xml like this :根据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>

But somehow it is not working when I'm trying to mvnw the project, it's giving me :但是不知何故,当我尝试 mvnw 项目时它不起作用,它给了我:

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

I managed to get it work while passing below parameters to MAVEN_OPTS but I would like to do so with settings.xml file only.我在将以下参数传递给 MAVEN_OPTS 时设法让它工作,但我只想使用 settings.xml 文件这样做。

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

Anyone can help ?任何人都可以帮忙吗?

Thanks in advance.提前致谢。

It seems Maven Wrapper does not use the proxy variables from Maven settings. Maven Wrapper 似乎不使用 Maven 设置中的代理变量。 The Downloader does not configure any proxy, so this means Java system properties must be used. 下载器不配置任何代理,因此这意味着必须使用 Java 系统属性。 For authentication, it just looks for the system property http.proxyUser and uses it .对于身份验证,它只查找系统属性http.proxyUser使用它

Setting the MAVEN_OPTS (as you mentioned and also here ) works:设置 MAVEN_OPTS(如您所提到的和这里的)有效:

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

or要么

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

The mvnw script also pulls in a file .mvn/jvm.config from the project path which can include these properties: mvnw 脚本还会从项目路径中提取一个文件.mvn/jvm.config ,其中可以包含以下属性:

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

I've opened a pull request ( #446 ) to add this info to the JHipster documentation.我打开了一个拉取请求 ( #446 ) 将此信息添加到 JHipster 文档中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM