简体   繁体   English

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

[英]my pom.xml install and build fail

This is my pom.xml file for a java project that works with selenium to create a set of tests. 这是我的Java项目的pom.xml文件,该项目与selenium一起使用以创建一组测试。

<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>

when I build it I get the following errors: 构建它时,出现以下错误:

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.

and

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]

As for the error in SLF4J, you can actually check the URL it mention ( http://www.slf4j.org/codes.html#StaticLoggerBinder ). 至于SLF4J中的错误,您实际上可以检查它提到的URL( http://www.slf4j.org/codes.html#StaticLoggerBinder )。

As for the error when you run the application, the error is this 至于运行应用程序时的错误,错误是这样的

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

Seems like the error is happened when Selenium is trying to load the firefox driver as the selenium firefox driver version 2.47.1 is build with java version 7. Selenium尝试加载firefox驱动程序时似乎发生了错误,因为使用Java 7版构建了selenium firefox驱动程序版本2.47.1。

Try to run the application with higher java version to use jdk version 7 or try install the older version of firefox driver. 尝试以更高的Java版本运行应用程序以使用jdk版本7,或者尝试安装旧版的firefox驱动程序。

Build with Java 7 or higher and your second problem should be fixed. 使用Java 7或更高版本进行构建,应该解决第二个问题。

According to your error, the class org.openqa.selenium.WebDriver has the class version of 51.0 , which suggests it's built for the target version of Java 7 . 根据您的错误,类org.openqa.selenium.WebDriver的类版本为51.0 ,这表明它是为Java 7的目标版本构建的。 Since you're using Java 6 , loading that class fails. 由于您使用的是Java 6 ,因此无法加载该类。 So upgrading your Java will fix the InvocationTargetException . 因此,升级Java将修复InvocationTargetException

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM