我正在創建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