Maven proxy settings not working
我在conf / settings.xml中设置了Maven代理设置
1 2 3 4 5 6 | <proxy> true</active> <protocol>http</protocol> <host>proxy.my-company.com</host> <port>8080</port> </proxy> |
但是当我运行maven build时,出现以下错误。 有人可以帮忙吗
1 | [WARNING] The POM for org.apache.maven.wagon:wagon-ssh:jar:2.2 is missing, no dependency information available |
详细日志
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | mvn -X Apache Maven 3.0.4 (r1232337; 2012-01-17 03:44:56-0500) Maven home: C:\\tools\\apache-maven-3.0.4 Java version: 1.6.0_12, vendor: Sun Microsystems Inc. Java home: C:\\tools\\Java\\jdk1.6.0_12\\jre Default locale: en_US, platform encoding: Cp1252 OS name:"windows xp", version:"5.1", arch:"x86", family:"windows" [INFO] Error stacktraces are turned on. [DEBUG] Reading global settings from C:\\tools\\apache-maven-3.0.4\\conf\\settings.xml [DEBUG] Reading user settings from C:\\Documents and Settings\\desibaba\\.m2\\settings.xml [DEBUG] Using local repository at C:\\Documents and Settings\\desibaba\\.m2\ epository [DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10 for C:\\Documents and Settings\\desibaba\\.m2\ epository [INFO] Scanning for projects... [DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://repo.maven.apache.org/maven2 via proxy.my-company.com:8080 as null Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon-ssh/2.2/wagon-ssh-2.2.pom [DEBUG] Writing resolution tracking file C:\\Documents and Settings\\desibaba\\.m2\ epository\\org\\apache\\maven\\wagon\\wagon-ssh\\2.2\\wagon-ssh-2.2.pom.lastUpdated [WARNING] The POM for org.apache.maven.wagon:wagon-ssh:jar:2.2 is missing, no dependency information available [DEBUG] org.apache.maven.wagon:wagon-ssh:jar:2.2: [DEBUG] org.codehaus.plexus:plexus-utils:jar:1.1:runtime [DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://repo.maven.apache.org/maven2 via proxy.my-company.com:8080 as null Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon-ssh/2.2/wagon-ssh-2.2.jar Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar [DEBUG] Writing resolution tracking file C:\\Documents and Settings\\desibaba\\.m2\ epository\\org\\apache\\maven\\wagon\\wagon-ssh\\2.2\\wagon-ssh-2.2.jar.lastUpd ated [DEBUG] Writing resolution tracking file C:\\Documents and Settings\\desibaba\\.m2\ epository\\org\\codehaus\\plexus\\plexus-utils\\1.1\\plexus-utils-1.1.jar.last Updated [DEBUG] Looking up lifecyle mappings for packaging pom from ClassRealm[plexus.core, parent: null] [ERROR] The build could not read 1 project -> [Help 1] org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs: [ERROR] Unresolveable build extension: Plugin org.apache.maven.wagon:wagon-ssh:2.2 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.apache.maven.wagon:wagon-ssh:jar:2.2, org.codehaus.plexus:plexus-utils:jar:1.1: Could not find artifact org.apache.maven.wagon:wagon-ssh:jar:2.2 in central (http://repo.maven.apache.org/maven2) @ at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:363) at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:636) at org.apache.maven.DefaultMaven.getProjectsForMavenReactor(DefaultMaven.java:585) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:234) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) [ERROR] [ERROR] The project xxx (C:\\t1\\9630727\\pom.xml) has 1 error [ERROR] Unresolveable build extension: Plugin org.apache.maven.wagon:wagon-ssh:2.2 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.apache.maven.wagon:wagon-ssh:jar:2.2, org.codehaus.plexus:plexus-utils:jar:1.1: Could not find artifact org.apache.maven.wagon:wagon-ssh:jar:2.2 in central (http://repo.maven.apache.org/maven2) -> [Help 2] org.apache.maven.plugin.PluginResolutionException: Plugin org.apache.maven.wagon:wagon-ssh:2.2 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.apache.maven.wagon:wagon-ssh:jar:2.2, org.codehaus.plexus:plexus-utils:jar:1.1: Could not find artifactorg.apache.maven.wagon:wagon-ssh:jar:2.2 in central (http://repo.maven.apache.org/maven2) |
我无法使用MVN 3.0.4做到这一点,但我却使用3.0.3
在3.0.4版本中似乎是一个错误。
上面的jira条目为Maven 3.0.4错误提供了一种解决方法:添加
1 2 3 4 5 6 7 8 9 10 | <build> <extensions> <extension> <!-- this extension is required by wagon in order to pass the proxy --> <groupId>org.apache.maven.wagon</groupId> wagon-http-lightweight</artifactId> <version>2.2</version> </extension> </extensions> </build> |
到您的
这对我有用
无需触摸您的POM,您可以将此库添加到M2_HOME / lib / ext
并在您的settings.xml中使用以下代理设置。
1 2 3 4 5 | <proxy> ... <username>DOMAIN\\USERNAME</username> <password>PASSWORD</password> ... |
我尝试将代理设置引入到几个不同位置的settings.xml文件中,但是似乎在运行时都没有选择代理设置。
但是,我发现有一个环境变量
1 2 | MAVEN_OPTS -Dhttp.proxyHost=proxy.myproxy.com -Dhttp.proxyPort=80 -Dhttps.proxyHost=proxy.myproxy.com -Dhttps.proxyPort=80 |
您的设置文件应如下所示:
1 2 3 4 5 6 7 8 9 10 11 12 | <settings> <proxies> <proxy> true</active> <protocol>http</protocol> <username><username-optional></username> <password><password-optional></password> <host><hostname></host> <port><port></port> </proxy> </proxies> </settings> |
如果这不起作用,请尝试将代理设置放到IE之类的浏览器中,看看它是否有效。另外,请尝试直接点击代理以确保它不是代理配置脚本。我不知道maven是否能和那些人打得很好。
尽管如果它是配置脚本,但该脚本应列出您要使用的正确代理。
编辑
我看到您正在使用conf / settings.xml表单,它在哪里?通常,settings.xml文件位于:
/path/to/user/home/.m2/settings.xml
为您在Windows中
C:\\Documents and Settings\\username\\.m2\\settings.xml
要么
C:\\users\\username\\.m2\\settings.xml
或直接将其放在您的Maven项目POM文件中。
使用mvn -X查看settings.xml的阅读顺序
使用mvn help:effective-settings立即查看有效设置
我有类似的问题。添加
标签问题已解决。
请注意,必须用正确的服务器替换
1 2 3 4 5 6 7 | <proxy> ... ... <nonProxyHosts>localhost|127.0.0.1|zzz.zz.com</nonProxyHosts> ... ... </proxy> |
有关详细信息,请访问http://maven.apache.org/guides/mini/guide-proxies.html
maven有两个settings.xml,具体取决于您在IDE中引用的settings.xml。确保代理信息在您引用的那个中可用。
C:\ Users ... m2 \ repository
apache-maven-X.X
在我的情况下,代理信息是从第n点获取的。 1,但是我试图修改Maven目录中的settings.xml
请原谅我恢复了这样一个旧的线程,但这也许可以帮助遇到相同错误的人。
我遇到了@OP描述的相同问题。我结合了此处描述的一些解决方案尝试,并且对我有用。
问题简要说明:
我用Java编写了一个小型聊天程序,效果很好。几天后,我有一台新的笔记本电脑在工作,不得不安装和转移所有东西。我在两台笔记本电脑上都使用了Eclipse(版本:Neon.2版本(4.6.2)),唯一的区别是,我在旧笔记本电脑上使用了Maven插件,而在新笔记本电脑上我直接安装了Maven。
我该怎么解决这个问题?
首先,按照Maven在本代理指南中的描述,将代理设置写入
注意:我更改了
然后我读了@Vijay Krish的评论
1 | "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." |
没有settings.xml,所以我只是将其从
我希望这对于任何在此问题上苦苦挣扎的人都是有用的。
最好的祝福
如果您不支持NTLM代理,请参考适用于我的解决方案!
如果您正在使用某些IntelliJ等IDE,请确保您正在更改IDE使用的同一Maven的settings.xml!我的意思是可能是捆绑了Maven,如果您更改系统的maven settings.xml很显然将无法使用!所以请检查IDE配置。如果需要更多帮助,请指定IDE名称。
是的,这很傻,但值得一试!检查系统路径环境变量中的maven路径,该变量与您要更新的settings.xml完全相同。
希望这可以帮助!
我不确定这是否是您的问题,但我注意到必须确保https代理位于http代理之前才能使用https代理。可能是因为它们在我的配置中是相同的主机名。