【问题标题】:my pom.xml install and build fail我的 pom.xml 安装和构建失败
【发布时间】:2015-09-28 08:23:58
【问题描述】:

这是我的 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]

【问题讨论】:

  • 为什么不尝试添加 slf4j 依赖项?
  • 您使用的是哪个 Java 版本?
  • @Paolof76 我做了,它给出了同样的错误

标签: java maven selenium


【解决方案1】:

至于SLF4J中的错误,你可以实际查看它提到的URL(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驱动程序。

【讨论】:

    【解决方案2】:

    使用 Java 7 或更高版本构建,您的第二个问题应该得到解决。

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

    【讨论】:

      猜你喜欢
      • 2019-10-16
      • 1970-01-01
      • 2017-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-16
      相关资源
      最近更新 更多