Maven proxy settings not working

后端 未结 10 1935
别那么骄傲
别那么骄傲 2020-12-05 15:53

I have setup maven proxy settings in conf/settings.xml as


  true
  http
  

        
相关标签:
10条回答
  • 2020-12-05 16:12

    I'm not able to do this with MVN 3.0.4 but I do with 3.0.3

    It seems to be a bug in the 3.0.4 release.

    The jira entry above gives a workaround for the maven 3.0.4 bug: add

    <build>
        <extensions>
            <extension>
                <!-- this extension is required by wagon in order to pass the proxy -->
                <groupId>org.apache.maven.wagon</groupId>
                <artifactId>wagon-http-lightweight</artifactId>
                <version>2.2</version>
            </extension>
        </extensions>
    </build>
    

    to your pom.xml

    This worked for me

    0 讨论(0)
  • 2020-12-05 16:15

    Without touching your POM you can add this library to M2_HOME/lib/ext and use the following proxy settings into your settings.xml.

    <proxy>
    ...
      <username>DOMAIN\USERNAME</username>
      <password>PASSWORD</password>
    ...
    

    0 讨论(0)
  • 2020-12-05 16:19

    Excuse me for reviving such an old thread, but maybe this'll help someone having the same error.

    I ran into the same problem as described by @OP. I combined some of the solution attempts described in here and it worked for me.

    Brief problem description:

    I've written a small chat program in java which worked fine. A few days later I got a new laptop at work and had to install and transfer everything. I used Eclipse (Version: Neon.2 Release (4.6.2)) on both of my laptops, the only difference was, that I used a Maven plugin for Eclipse on my old laptop and on the new one I installed Maven directly.

    What did I do to solve the problem?

    First, I wrote the proxy settings into settings.xml, as described in this proxy guide by Maven. It didn't work for me though.

    NOTE: I changed the settings.xml under C:\Program Files\apache-maven-3.3.9\conf

    Then I read the comment by @Vijay Krish

    "Note: We have to add above elements in settings.xml available under 'user.home\.m2' folder. If file doesn't exists already in the mentioned path, create it."
    

    There was no settings.xml so I just copied the one from C:\Program Files\apache-maven-3.3.9\conf to user.home\.m2 and tried again to run a Maven build and it worked fine.

    I hope that this'll be useful for anyone struggling with this problem.

    Best regards

    0 讨论(0)
  • 2020-12-05 16:23

    Your settings file should look like the following:

    <settings>
        <proxies>
            <proxy>
                <active>true</active>
                <protocol>http</protocol>
                <username><username-optional></username>
                <password><password-optional></password>
                <host><hostname></host>
                <port><port></port>
            </proxy>
        </proxies>
    </settings>
    

    If that's not working, then try putting your proxy settings into a browser like IE and see if it works. Also try hitting the proxy directly to ensure it's not a proxy configuration script. I don't know if maven plays well with those or not.

    Though if it is a configuration script, the script should list out the correct proxy to use in your situation.

    EDIT

    I see you are working form conf/settings.xml where is that located? Normally the settings.xml file is located in:

    /path/to/user/home/.m2/settings.xml

    for you in windows that would be

    C:\Documents and Settings\username\.m2\settings.xml

    or

    C:\users\username\.m2\settings.xml

    or put it directly in your maven projects POM file.

    0 讨论(0)
  • 2020-12-05 16:29

    I tried introducing the proxy settings to the settings.xml file in several different locations, but it seems like none of them were picked up during runtime.

    However, I discovered that there is an environment variable MAVEN_OPTS where I was finally able to set the proxy info and have it reflected at runtime:

    MAVEN_OPTS
    -Dhttp.proxyHost=proxy.myproxy.com -Dhttp.proxyPort=80 -Dhttps.proxyHost=proxy.myproxy.com -Dhttps.proxyPort=80
    

    0 讨论(0)
  • 2020-12-05 16:29

    There are two settings.xml for maven depending on which settings.xml you are referring in your IDE .Make sure the proxy information is available in the one you are referring.

    1. One is available in .m2 directory
      C:\Users...m2\repository
    2. Other one is available in conf directory of the Maven folder.
      apache-maven-X.X.X

    In my case the proxy information were being fetched from point no. 1 but i was trying to modify the the settings.xml in maven directory

    0 讨论(0)
提交回复
热议问题