java - 无法使用 jmeter maven 插件运行 jmeter
问题描述
我正在尝试使用 maven POM.xml 运行我的 jmx 文件,该文件是 src/test/jmeter,但出现错误
我在 pom.xml 中提供了 5.1.1 版本,仍然说这个插件需要 5.1.1 版本的 jmeter。
这个插件会自动下载 jmeter 吗?还是我必须手动下载并保存在 src/test/jmeter 文件夹中?
下面使用的版本:
<dependency>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.9.0</version>
</dependency>
尝试更改 jmeter maven 插件的版本,仍然出现同样的错误
这是我在 maven 代码下运行时出现的错误: mvn clean install -DskipTests -Dskip.report.generation=true -Djmeter.version=5.1.1
[ERROR] Failed to execute goal com.lazerycode.jmeter:jmeter-maven-plugin:2.9.0:jmeter (jmeter-tests) on project WebserviceAutomation: The plugin com.lazerycode.jmeter:jmeter-maven-plugin:2.9.0 requires Maven version 3.5.2
解决方案
根据JMeter Maven 插件文档的当前版本
最新版本是2.9.0,它需要Maven >= 3.5.2并且默认为 Apache JMeter 5.1.1。
所以请确保获取Maven 3.5.2或最新版本
最小的工作pom.xml文件将类似于:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>jmeter-maven</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>maven-jmeter-demo</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.9.0</version>
<executions>
<!-- Generate JMeter configuration -->
<execution>
<id>configuration</id>
<goals>
<goal>configure</goal>
</goals>
</execution>
<!-- Run JMeter tests -->
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
<!-- Fail build on errors in test -->
<execution>
<id>jmeter-check-results</id>
<goals>
<goal>results</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
只需创建src/test/jmeter
文件夹并将您的 JMX 脚本放在那里,一旦完成,您应该能够使用mvn verify
命令启动测试
推荐阅读
- java - 按属性隔离列表
- android - 按钮和工具栏内容之间的共享元素过渡
- java - 如何将类名存储在任何变量中并将其与 instanceof 运算符一起使用
- apache-nifi - 如何使用rest api或cli在nifi 1.7的处理器中删除流文件?
- google-analytics - 我可以编辑“页面”网址以使其在报告中更具可读性吗?
- python - 如何去除晶圆图生成图像中的十字准线和轮廓?
- java - 如何通过 HTTP 将 UTF-8 字符作为字符串发送
- node.js - Sequelize V5 - 创建模型时不支持 BOOLEAN 数据类型
- matlab - Eigen C++ 中数学表达式的内联计算
- javascript - 为什么 jwt.sign() 方法仅适用于字符串密钥?