使用 Maven 执行 jmeter 测试时出错 "You must specify a valid lifecycle phase or a goal in the format"

Error "You must specify a valid lifecycle phase or a goal in the format" while executing jmeter test using Maven

我正在使用 运行 jmeter 文件的 POM 文件内容如下所示,但它在命令 prompt.Please 中抛出类似 "You must specify a valid lifecycle phase or a goal in the format" 的错误

    <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.example</groupId>
  <artifactId>jmeter-maven</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>jmeter-maven</name>
  <url>http://maven.apache.org</url>
  <build>
    <plugins>
      <plugin>
        <groupId>com.lazerycode.jmeter</groupId>
        <artifactId>jmeter-maven-plugin</artifactId>
        <version>1.4.1</version>
        <executions>
          <execution>
            <id>jmeter-tests</id>
            <phase>verify</phase>
            <goals>
              <goal>jmeter</goal>
            </goals>
            <configuration>
              <jMeterProcessJVMSettings>
                  <xms>1024</xms>
                  <xms>1024</xms>
                  <arguments>
                     <argument>-Xprof</argument>
                     <argument>-Xfuture</argument>
                  </arguments>
               </jMeterProcessJVMSettings>
               <propertiesUser>
                 <users>${users}</users>
             <rampUp>${rampUp}</rampUp>
                 <loop>${loopcount}</loop>
                 <url>${url}</url>
                 <suite>${suite}</suite>
               </propertiesUser>
               <testFilesIncluded>
                   <jMeterTestFile>testplans/Ecommersce.jmx</jMeterTestFile>
               </testFilesIncluded>
             </configuration>
           </execution>
         </executions>
        </plugin>
       </plugins>
      </build>

      <dependencies>
          <!-- https://mvnrepository.com/artifact/com.lazerycode.jmeter/jmeter-mavan-plugin -->
         <dependency>
              <groupId>com.lazerycode.jmeter</groupId>
              <artifactId>com.lazerycode.jmeter</artifactId>
              <version>2.1.0</version>
         </dependency>
      </dependencies>
   </project>

当我使用 Maven POM 运行 Jmeter 文件时,它在命令提示符中抛出类似 "You must specify a valid lifecycle phase or a goal in the format" 的错误

正在执行命令时出现以下错误 window

  C:\Desktop\jmeter\frameworkmaven>mvn verify -Dusers=1 DrampUp=1 Dloopcount=1 Durl=www.testing.com -Dsuite=framework
                [INFO] Scanning for projects...
                    [WARNING]
                    [WARNING] Some problems were encountered while building the effective model for com.example:jmeter-maven:jar:1.0-SNAPSHOT
                    [WARNING] The expression ${url} is deprecated. Please use ${project.url} instead.
                    [WARNING]
                    [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
                    [WARNING]
                    [WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
                    [WARNING]
                    [INFO]
                    [INFO] ----------------------< com.example:jmeter-maven >----------------------
                    [INFO] Building jmeter-maven 1.0-SNAPSHOT
                    [INFO] --------------------------------[ jar ]---------------------------------
                    [INFO] ------------------------------------------------------------------------
                    [INFO] BUILD FAILURE
                    [INFO] ------------------------------------------------------------------------
                    [INFO] Total time: 0.192 s
                    [INFO] Finished at: 2018-11-01T21:16:26+05:30
                    [INFO] ------------------------------------------------------------------------


      [ERROR] Unknown lifecycle phase "DrampUp=1". You must specify a valid 

    lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]

            [ERROR]
            [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
            [ERROR] Re-run Maven using the -X switch to enable full debug logging.
            [ERROR]
            [ERROR] For more information about the errors and possible solutions, please read the following articles:
            [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/LifecyclePhaseNotFoundException

请帮忙解决这个问题

根据 Jens 的评论,您的命令行应该是:

mvn -Dusers=1 -DrampUp=1 -Dloopcount=1 -Durl=www.testing.com -Dsuite=framework clean verify

另外:

  • 你应该使用 version 2.8.0 of jmeter-maven-plugin
  • 你应该删除这个没用的块

    <dependencies>
         <!-- https://mvnrepository.com/artifact/com.lazerycode.jmeter/jmeter-mavan-plugin -->
        <dependency>
          <groupId>com.lazerycode.jmeter</groupId>
          <artifactId>com.lazerycode.jmeter</artifactId>
          <version>2.1.0</version>
          </dependency>
       </dependencies>