我正在创建maven应用程序,我从网站获取信息。未找到maven包类selenium Web驱动程序
我创建Maven的包,但是当我使用命令运行的jar: “Java的罐子APP-1.0-SNAPSHOT.jar” 我得到这个错误:
“抛出java.lang.ClassNotFoundException:org.openqa。 selenium.WebDriver“
它运行良好,当我在IntelliJ中运行它。
这是我的POM:
<groupId>app</groupId>
<artifactId>app</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
<version>2.52.0</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.0.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>sample.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>runtime</includeScope>
<outputDirectory>${project.build.directory}/dependency-jars/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
请帮我找出什么是错的。谢谢!
感谢您的回复。不幸的是它没有帮助。 Htmlunit驱动程序最新版本是2.52.0。我将selenium-java的版本更改为2.52.0,但没有成功。 – Liam
您是否尝试添加硒服务器(用于版本2.52.0)的依赖关系? –
是的,仍然是相同的情况:( – Liam