【发布时间】:2014-05-04 02:39:26
【问题描述】:
我已经在谷歌上搜索了好几天,试图弄清楚如何做到这一点,如果有人在此之前这样做过,我将不胜感激。
我有一个我在 IntelliJ 中创建的自动化测试项目,它可以自动化用户与 Web 应用程序的交互。
我想将该自动化测试(用 Java 创建,使用 Selenium 和 TestNG)放入一个可执行的 jar 文件中,其他人可以通过双击该 jar 文件来运行该文件。
每次我尝试通过导航到项目结构 -> 工件 -> + -> Jar -> 从具有依赖项的模块来创建 jar 文件时,它最终都会创建一个声明它的 jar,
"Could not find or load the main class <package.MainClass> "
当我尝试使用以下命令运行它时:
java -jar MyProject.jar <Manifest Path>
知道为什么我不断收到此错误,或者有办法成功执行此操作吗?
另外,这是我的 pom.xml:
<groupId>TestAutomation</groupId>
<artifactId>TestAutomation</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.test.automation.Executable</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.39.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.40.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.1.1</version>
<scope>test</scope>
</dependency>
</dependencies>
【问题讨论】:
标签: java selenium intellij-idea jar executable-jar