我为Jmeter中的负载测试的HTTP请求编写了以下Wiremock代码:
在eclipse中运行时出现以下错误:
谁能帮我解决这个问题?
最佳答案
您指定了两个不同的端口号8081、8080
wiremock将仅在指定的端口上运行,以下代码在localhost:8080 / abc / xyz上有效
package com.wiremock;
import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.client.WireMock;
import
com.github.tomakehurst.wiremock.stubbing.StubMapping;
import static
com.github.tomakehurst.wiremock.client.WireMock.*;
public class WireMockMain {
public static void main(String[] args) {
// TODO Auto-generated method stub
WireMockServer wireMockServer = new WireMockServer(8080);
//configureFor("localhost", 8081);
wireMockServer.start();
StubMapping foo = WireMock.stubFor(get(urlPathEqualTo("/abc/xyz"))
.willReturn(aResponse()
.withStatus(200)
.withBody("{\"message\": \"Hello World\"}")));
wireMockServer.addStubMapping(foo);
}
}
关于java - Wiiremock HTTP失败错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51071063/