java - 运行使用 maven-shade 创建的 TestNG jar 文件时无法找到或加载主类
问题描述
TestNG
我使用 maven-shade 插件从我的测试中创建了一个 jar 文件。当我尝试运行它时,我得到
无法找到或加载主类 testng.xml
但该文件存在。这是我的项目树:
这些是我的pom.xml
插件:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>testng.xml</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
如何让它找到 testng.xml 文件并运行它?
解决方案
推荐阅读
- javascript - 在数组中添加对象的值 - javascript
- java - Jackson Parsing for json object inside json
- vba - 使用 Visual Basic 在 Excel 中设置宏
- wso2 - WSO2 分布式设置 - 无法通过网关访问 API
- javascript - Reapply filter for GeoJSON in Leaflet
- go - How does .(type) work in go
- python - 一个初学者制作的python数字猜谜游戏。请帮助优化和解决问题
- google-calendar-api - How can we filter the google calendar events with attendee name
- javascript - Webrtc adding ice candidate to remote peer
- javascript - Firefox 上的 HTTPS iFrame 出现 SecurityError