0

运行命令时,我在 Maven 中遇到了以下错误

C:\Users\Man\SelProj>mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SelProj 1.0
[INFO] ------------------------------------------------------------------------
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.735s
[INFO] Finished at: Sun Apr 21 15:25:23 EST 2013
[INFO] Final Memory: 6M/106M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.4.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:m
aven-clean-plugin:jar:2.4.1: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.4.1 from/to central (http://repo.maven.apache.org/maven2): Connection to
http://repo.maven.apache.org refused: connect: Address is invalid on local machine, or port is not valid on remote machine -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
C:\Users\Man\SelProj>

我的 POM.xml 文件如下,我将 POM 文件放在运行 >mvn clean install cmmand 的文件夹中

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>SelProj</groupId>
        <artifactId>SelProj</artifactId>
        <version>1.0</version>
        <dependencies>
        <!-- Selenium2 dependency -->
            <dependency>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-java</artifactId>
                <version>2.32.0</version>
            </dependency>
            <dependency>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-chrome-driver</artifactId>
                <version>2.5.0</version>
            </dependency>
        </dependencies>
</project>

可能是什么原因。我在 Windows 8(64 位)上运行它

4

2 回答 2

0

我也有同样的问题。尝试使用>mvn install不带clean.

于 2013-04-25T02:46:14.377 回答
0

由于您可以通过网络浏览器访问它,我知道互联网连接没有任何问题。

有两个重要的可能根本原因如下: -

1.代理

如果您在代理后面,请将proxy配置添加到settings.xml例如

<settings>
  .
  .
  <proxies>
   <proxy>
      <active>true</active>
      <protocol>http</protocol>
      <host>proxy.somewhere.com</host>
      <port>8080</port>
      <username>proxyuser</username>
      <password>somepassword</password>
      <nonProxyHosts>www.google.com|*.somewhere.com</nonProxyHosts>
    </proxy>
  </proxies>
  .
  .
</settings>

请参阅Maven - 使用代理指南了解更多信息。

2. 防病毒/防火墙问题

Firewall有时Anti-virus 会阻止 Java正常运行,或者Windows Firewall(和各种其他防火墙)主动阻止 Java.exe访问 Internet 以“下载东西”,这是 Maven 的关键部分。您可能需要配置防火墙或防病毒软件以添加例外以允许此类操作

有关详细信息,请参阅Maven - Windows 上的 Maven 。

我希望这可能会有所帮助。

于 2013-04-22T03:35:38.473 回答