我在Eclipse中有maven项目进行seleniumm测试。我尝试构建测试,但得到构建错误:
Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.5 from/to central (http://repo.maven.apache.org/maven2): connection timed out to http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.5/maven-resources-plugin-2.5.pom -> [Help 1]
我通过右键单击pom文件开始构建并选择Run as - Maven test 我的pom文件看起来像:
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tests</groupId>
<artifactId>ui-tests</artifactId>
<version>1.0.0</version>
<profiles>
<profile>
<id>tests</id>
<properties>
<browser.name>ie</browser.name>
</properties>
<build>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.10</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${project.basedir}/src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>2.33.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.5</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>2.33.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>2.33.0</version>
</dependency>
</dependencies>
我搜索了解决方案并发现我需要为maven设置代理,所以我将以下内容添加到settings.xml:
<proxies>
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<host>10.192.168.87</host>
<port>8080</port>
</proxy>
此外,我发现可以通过手动下载错过的资源来解决问题。我下载org.apache.maven.plugins:maven-resources-plugin并找出wasn&#t; t .m2目录。我检查maven版本,它工作,所以我创建这样的目录manualy并在settings.xml中设置它的路径。在此之后,我将下载的插件放到.m2。 但错误并没有消失。有人可以告诉我如何解决这个问题吗?