【问题标题】:Not able to run jmeter using jmeter maven plugin无法使用 jmeter maven 插件运行 jmeter
【发布时间】:2019-10-24 06:21:46
【问题描述】:

我正在尝试使用 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

【问题讨论】:

  • 您是否尝试过使用 Maven 版本 >= 3.5.2?
  • 我有一个疑问,我在哪里提到 5.1.1?如果在 POM.xml 中,那么是的,我提到了 5.1.1,如下所示: 5.1.1 in jmeter maven plugin
  • 5.1.1 为默认版本
  • 如果我只是使用命令通过命令行运行它,我不会收到任何错误:mvn clean install。但是,没有执行任何请求,并且只有 0 个请求通过了构建。

标签: java maven jmeter


【解决方案1】:

根据JMeter Maven Plugin 文档的当前版本

最新版本是 2.9.0,它需要 Maven >= 3.5.2 并且默认为 Apache JMeter 5.1.1

所以请确保获得Maven 3.5.2 或只是latest version

最小的工作 pom.xml file 是这样的:

<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 命令启动测试

更多信息:Five Ways To Launch a JMeter Test without Using the JMeter GUI

【讨论】:

  • 实际上在执行的地方,我收到此消息插件执行未包含在生命周期配置中:com.lazerycode.jmeter:jmeter-maven-plugin:2.9.0:configure (execution: configuration, phase : compile) ,所以使用选项“忽略此 Eclipse 首选项”忽略此是否会导致任何问题?我观察到在目标文件夹中 jmeter 的 bin 文件夹下,我没有看到任何文件被创建
  • 我从 Eclipse 工作场所删除了偏好,仍然面临同样的问题。不确定它在哪里检查 jmeter 的版本,正如我所说的 target/jmeter 中的 bin 文件夹是空的,我怀疑这个插件正在查看 bin 文件夹并说它需要 3.5.2?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-04-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-27
  • 2012-10-03
相关资源
最近更新 更多