本文介绍了jmeter maven-运行的jmx文件给出错误:找不到或加载主类org.apache.jmeter.NewDriver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为jmeter设置一个Maven项目.在src/test/java中添加了jmx文件.
Setup a maven project for jmeter. Added the jmx file in src/test/java.
尝试运行jmx文件时,在控制台中出现以下错误.错误:找不到或加载主类org.apache.jmeter.NewDriver
When trying to run the jmx file, getting the following error in the console.Error: Could not find or load main class org.apache.jmeter.NewDriver
这是我的pom.xml
Here is my pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>com.companyname.automation</groupId>
<artifactId>apiautomation</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.4.1</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient-osgi</artifactId>
<version>4.3</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.3</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3-beta1</version>
</dependency>
</dependencies>
推荐答案
设置中几乎没有不一致之处:
There are few inconsistencies in your setup:
- JMX文件应位于src/test/ jmeter 文件夹下
-
您需要在
<version>1.4.1</version>
行之后添加以下部分:
- JMX file(s) should live under src/test/jmeter folder
You need to add the following section after
<version>1.4.1</version>
line:
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
mvn clean verify
进行测试. mvn clean verify
to run your test. 参考文献:
- JMeter Maven的
- 基本配置一章插件文档
- 五种方法中的使用APACHE MAVEN"部分在不使用JMeter GUI的情况下启动JMeter测试
- Basic Configuration chapter of JMeter Maven Plugin documentation
- USE APACHE MAVEN section of Five Ways To Launch a JMeter Test without Using the JMeter GUI
这篇关于jmeter maven-运行的jmx文件给出错误:找不到或加载主类org.apache.jmeter.NewDriver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!