简体   繁体   中英

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 :

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

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 opened a pull request ( #446 ) to add this info to the JHipster documentation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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