JHipster configure maven wrapper proxy

僤鯓⒐⒋嵵緔 提交于 2019-11-29 17:55:37

问题


According to https://jhipster.github.io/configuring-a-corporate-proxy/ I have set up my proxy settings in /.m2/settings.xml like this :

  <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 :

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.

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

Anyone can help ?

Thanks in advance.


回答1:


It seems Maven Wrapper does not use the proxy variables from Maven settings. The Downloader does not configure any proxy, so this means Java system properties must be used. For authentication, it just looks for the system property http.proxyUser and uses it.

Setting the MAVEN_OPTS (as you mentioned and also here) works:

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:

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

I've openend a pull request (#446) to add this info to the JHipster documentation.



来源:https://stackoverflow.com/questions/41187743/jhipster-configure-maven-wrapper-proxy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!