我的pom.xml安装和构建失败

时间:2015-09-28 08:23:58

标签: java maven selenium

这是我的pom.xml文件,用于与selenium一起创建一组测试的java项目。

<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>TestMach</groupId>
    <artifactId>TestMach</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>MainTestMach</name>
    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.3</version>
            <executions>
                <execution>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <mainClass>main.ExtractMain</mainClass>
                <executable>java</executable>
                <arguments>
                    <argument>-classpath</argument>
                </arguments>
            </configuration>
        </plugin>

        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.3-1100-jdbc4</version>
        </dependency>

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-firefox-driver</artifactId>
            <version>2.47.1</version>
        </dependency>

        <dependency>
            <groupId>com.opera</groupId>
            <artifactId>operadriver</artifactId>
        </dependency>

        <dependency>
            <groupId>commons-configuration</groupId>
            <artifactId>commons-configuration</artifactId>
            <version>1.9</version>
        </dependency>

        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1</version>
        </dependency>

        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>2.3</version>
        </dependency>
    </dependencies>     
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.opera</groupId>
                <artifactId>operadriver</artifactId>
                <version>1.5</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.seleniumhq.selenium</groupId>
                        <artifactId>selenium-remote-driver</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
        </dependencies>
    </dependencyManagement>

</project>

当我构建它时,我收到以下错误:

LF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.3:java (default-cli) on project TestMach: An exception occured while executing the Java class. null: InvocationTargetException: org/openqa/selenium/WebDriver : Unsupported major.minor version 51.0 -> [Help 1]

2 个答案:

答案 0 :(得分:0)

至于SLF4J中的错误,您实际上可以检查它提到的网址(http://www.slf4j.org/codes.html#StaticLoggerBinder)。

关于运行应用程序时的错误,错误是这个

org/openqa/selenium/WebDriver : Unsupported major.minor version 51.0

当Selenium尝试加载firefox驱动程序时,似乎发生了错误,因为selenium firefox驱动程序版本2.47.1是使用java版本7构建的。

尝试使用更高版本的java运行应用程序以使用jdk版本7或尝试安装旧版本的firefox驱动程序。

答案 1 :(得分:0)

使用Java 7或更高版本构建,应修复第二个问题。

根据您的错误,班级org.openqa.selenium.WebDriver的班级版本为51.0,表明它是针对Java 7的目标版本构建的。由于您使用的是Java 6,因此加载该类失败。因此,升级Java将修复InvocationTargetException