java - Maven jmeter插件: SAXParseException: Content is not allowed in prolog

标签 java maven jmeter jmeter-plugins jmeter-maven-plugin

我的 jmeter jmx 文件中有这样的内容:

<stringProp name="SoapSampler.URL_DATA">http://192.168.0.1:8080/abc/Service</stringProp>

我在进行maven构建时使用jmeter maven插件来获取性能测试结果。它运行完美。

现在我将其更改为 jmeter 中的用户定义变量并尝试运行它。我收到以下错误:

“SAXParseException:序言中不允许出现内容”

jmx 文件中的更改:

      <elementProp name="server" elementType="Argument">
        <stringProp name="Argument.name">server</stringProp>
        <stringProp name="Argument.value">http://192.168.0.1:8080</stringProp>
        <stringProp name="Argument.metadata">=</stringProp>
      </elementProp>


<stringProp name="SoapSampler.URL_DATA">${server}/abc/Service</stringProp>

但是,如果直接从 jmeter GUI 执行,修改后的更改可以完美运行。仅在 maven 构建期间执行时才会失败。

这是我的 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.abc.def.performance</groupId>
<artifactId>abc-performance</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>



<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>



<build>
    <plugins>
        <plugin>
            <groupId>com.lazerycode.jmeter</groupId>
            <artifactId>jmeter-maven-plugin</artifactId>
            <version>1.9.0</version>
            <executions>
                <execution>
                    <id>jmeter-tests</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>jmeter</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
            </configuration>
        </plugin>
        <plugin>
            <groupId>com.lazerycode.jmeter</groupId>
            <artifactId>jmeter-analysis-maven-plugin</artifactId>
            <executions>
                <execution>
                    <phase>verify</phase>
                    <goals>
                        <goal>analyze</goal>
                    </goals>
                    <configuration>
                        <!-- An AntPath-Style pattern matching a JMeter XML result file to 
                            analyze. Must be a fully qualified path. File may be GZiped, must end in 
                            .gz then. Default: not set. Required. -->
                        <source>${project.build.directory}/**/*.jtl</source>
                        <!-- directory where to store analysis result files. Default: ${project.build.directory} 
                            Required. -->
                        <targetDirectory>${project.build.directory}/results</targetDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

最佳答案

确保jmeter.save.saveservice.output_format=xml并且 从 jmeter.properties 文件(jmeter 安装文件夹的 bin 文件夹内)中取消注释以下行:

jmeter.save.saveservice.output_format=xml
jmeter.save.saveservice.data_type=true
jmeter.save.saveservice.label=true
jmeter.save.saveservice.response_code=true
jmeter.save.saveservice.successful=true
jmeter.save.saveservice.thread_name=true

关于java - Maven jmeter插件: SAXParseException: Content is not allowed in prolog,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29739344/

相关文章:

java - 如何最好地使可读的过多构造函数参数

java - IntelliJ ajc : how to make exclusions from aspectj-maven-plugin work?

jmeter - 如何在 Jmeter Scheduler 中将开始和结束时间设置为变量

jmeter - jMeter 中 "Save Responses to a file"中的变量字段 -

performance - JMeter 的 nanoThreadSleep 属性 - 如何使用它?

java - 如何获取转发的转发者列表?

java - 在警告对话框后返回 JTextField 进行编辑

java - 签名的 Java 代码在 7.0 21 更新后不作为签名

java - Oracle ojdbc8 12.2.0.1错误的Pom编码

java - Maven 不运行 selenium 测试