2017-09-19 8 views
1

私はwiremockポートを設定しようとしています。それは常に以下の例外を与えます。wiremockサーバポートを設定できません

WireMockServer wireMockServer = new WireMockServer(WireMockConfiguration.options().port(PORT)); 

あなたはすでにそのようにそれを試してみました:私は、最新バージョンの2.8.0バージョンここで

Exception in thread "main" org.apache.http.conn.HttpHostConnectException: Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect 
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:159) 
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359) 
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381) 
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237) 
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185) 
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) 
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) 
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108) 
at com.github.tomakehurst.wiremock.client.HttpAdminClient.safelyExecuteRequest(HttpAdminClient.java:380) 
at com.github.tomakehurst.wiremock.client.HttpAdminClient.executeRequest(HttpAdminClient.java:368) 
at com.github.tomakehurst.wiremock.client.HttpAdminClient.addStubMapping(HttpAdminClient.java:110) 
at com.github.tomakehurst.wiremock.client.WireMock.register(WireMock.java:273) 
at com.github.tomakehurst.wiremock.client.WireMock.register(WireMock.java:268) 
at com.github.tomakehurst.wiremock.client.WireMock.givenThat(WireMock.java:99) 
at com.github.tomakehurst.wiremock.client.WireMock.stubFor(WireMock.java:103) 
at Testme.main(Testme.java:18) 

私のコード

public static void main(String args[]) 
{ 
    System.out.println("Starting server"); 
    WireMockServer wireMockServer = new WireMockServer(8090); 
    //Tried this one as well 
    //options.port(8090) 
    //WireMock.configureFor(8090); 
    wireMockServer.start(); 

    stubFor(get(urlEqualTo("/my/resource")) 
      .withHeader("Accept", equalTo("text/xml")) 
      .willReturn(aResponse() 
        .withStatus(200) 
        .withHeader("Content-Type", "text/xml") 
        .withBody("<response>Some content</response>"))); 
} 
+1

私は最新のバージョン2.8.0を使用しています – vkrams

答えて

1

は、私が使用しているを使用していますか?

0

最新のバージョン2.11.0以下の構文が適用されます

WireMockServer wireMockServer = new WireMockServer(new WireMockConfiguration().port(8088)

関連する問題