什么可能导致maven中的'错误传输文件'?

And*_*ell 11 maven-2

我在我的debian机器上安装了maven 2.2.1并收到以下错误

[WARNING] repository metadata for: 'org.apache.maven.plugins' could not be retrieved  from repository: central due to an error: Error transferring file: repository.exoplatform.org
Run Code Online (Sandbox Code Playgroud)

我能找到的与此问题相关的是它通常是由于没有正确配置代理设置或防火墙阻塞流量引起的,但我在这台机器上没有.此外,我在我的Windows机器上有相同的设置文件,它工作正常.

任何建议都会非常感激,因为我很难过.

exo@melb-web:~/test$ mvn -v
Apache Maven 2.2.1 (r801777; 2009-08-07 05:16:01+1000)
Java version: 1.5.0_22
Java home: /usr/local/bin/jdk1.5.0_22/jre
Default locale: en_AU, platform encoding: UTF-8
OS name: "linux" version: "2.6.22-3-amd64" arch: "i386" Family: "unix"
exo@melb-web:~/test$ mvn archetype:generate
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] org.apache.maven.plugins: checking for updates from central
[WARNING] repository metadata for: 'org.apache.maven.plugins' could not be retrieved from repository: central due to an error: Error transferring file: repository.exoplatform.org
[INFO] Repository 'central' will be blacklisted
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin 'org.apache.maven.plugins:maven-archetype-plugin' does not exist or no valid version could be found
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Wed Jun 30 10:18:33 EST 2010
[INFO] Final Memory: 2M/136M
[INFO] ------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)

*编辑*

我尝试删除settings.xml并生成一个新的maven项目.我得到了以下内容

exo@melb-web:~/test$ mvn archetype:generate
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] org.apache.maven.plugins: checking for updates from central
[WARNING] repository metadata for: 'org.apache.maven.plugins' could not be retrieved from repository: central due to an error: Error transferring file: repo1.maven.org
[INFO] Repository 'central' will be blacklisted
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin 'org.apache.maven.plugins:maven-archetype-plugin' does not exist or no valid version could be found
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Wed Jun 30 11:40:26 EST 2010
[INFO] Final Memory: 1M/136M
[INFO] ------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)

我认为这排除了它是settings.xml或pom的问题.有没有办法获得有关为什么maven无法连接到存储库的更多信息?

Jos*_*seK 10

我尝试了相同的命令并获得相同的错误消息,因此我使用调试标志运行.这会根据代理设置等提供不同的根异常.尝试运行相同的代码,以防您获得更好的详细输出.

mvn -X archetype:generate
Run Code Online (Sandbox Code Playgroud)

情况1:

机器未连接到网络(禁用电缆)会发出调试消息

[DEBUG] Exception
org.apache.maven.wagon.TransferFailedException: Error transferring file
...
Caused by: java.net.UnknownHostException: repo1.maven.org
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
[INFO] Repository 'central' will be blacklisted
Run Code Online (Sandbox Code Playgroud)

案例2:

连接错误代理的机器会发出调试消息

[DEBUG] Exception
org.apache.maven.wagon.TransferFailedException: Error transferring file
...
Caused by: java.net.ConnectException: Connection timed out: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
[INFO] Repository 'central' will be blacklisted
Run Code Online (Sandbox Code Playgroud)

这里的错误可能是403,连接重置或授权或访问禁止错误

案例3:

直接连接到互联网的机器

[DEBUG] Trying repository central
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-archet
ype-plugin/2.0-alpha-5/maven-archetype-plugin-2.0-alpha-5.jar
[DEBUG]   Artifact resolved
[INFO] ------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)

等等直到它起作用.


And*_*ell 3

只是为了结束这个循环——事实证明,这是 debian 可用于 java 解析主机名的库的问题。修复方法是为 java 应用新的 libdns,如此处所述http://www.ehow.com/how_4747553_fix-unknownhostexception-java-applications-ubuntu.html。完成此操作后,我就可以使用 jdk5 和 jdk6 运行 mvn。

  • 该链接现在似乎已损坏。 (11认同)