2017-03-22 407 views
0

我最近加入了一個項目。我是一個初學者。我的職責是創建服務器存根,創建SDK並使用SDk創建Java客戶端並與服務器存根通信。無法連接到服務器存根使用java客戶端

我使用創建的服務器存根,它使用

java -jar /data/Swagger/swagger-codegen-cli.jar generate \ 
    -i /data/AM/ame/ameee.json \ 
    -l spring --library spring-mvc\ 
    -o /data/stub/spring_mvc 

運行,

mvn clean package jetty:run 

網址是,

http://localhost:8002/api/swagger-ui.html 

產生使用SDK,

java -jar /data/Swagger/swagger-codegen-cli.jar generate \ 
    -i /data/AM/ame/ameee.json \ 
    -l java\ 
    -o /data/stub/SDK 

然後我編譯的SDK和進口.jar文件到我的客戶項目, 這是代碼,

import io.swagger.client.*; 
import io.swagger.client.auth.*; 
import io.swagger.client.model.*; 
import io.swagger.client.api.MonatizationAPIApi; 

import java.io.File; 
import java.util.*; 
public class MonatizationAPIApiExample { 
    public static void main(String[] args) { 

     MonatizationAPIApi apiInstance = new MonatizationAPIApi(); 

     try { 
      List<ParticipantType> result = apiInstance.getAllParticipantTypesUsingGET(); 
      System.out.println(result); 
     } catch (ApiException e) { 
      System.err.println("Exception when calling MonatizationAPIApi#getAllParticipantTypesUsingGET"); 
      e.printStackTrace(); 
     } 
    } 
} 

我還在試圖讓服務器存根的連接,

這是錯誤,

Exception when calling MonatizationAPIApi#getAllParticipantTypesUsingGET 
io.swagger.client.ApiException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:8080 
    at io.swagger.client.ApiClient.execute(ApiClient.java:984) 
    at io.swagger.client.api.MonatizationAPIApi.getAllParticipantTypesUsingGETWithHttpInfo(MonatizationAPIApi.java:878) 
    at io.swagger.client.api.MonatizationAPIApi.getAllParticipantTypesUsingGET(MonatizationAPIApi.java:865) 
    at MonatizationAPIApiExample.main(MonatizationAPIApiExample.java:19) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:483) 
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) 
Caused by: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:8080 
    at com.squareup.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:143) 
    at com.squareup.okhttp.internal.io.RealConnection.connect(RealConnection.java:112) 
    at com.squareup.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:184) 
    at com.squareup.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:126) 
    at com.squareup.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:95) 
    at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:281) 
    at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:224) 
    at com.squareup.okhttp.Call.getResponse(Call.java:286) 
    at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:243) 
    at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:205) 
    at com.squareup.okhttp.Call.execute(Call.java:80) 
    at io.swagger.client.ApiClient.execute(ApiClient.java:980) 
    ... 8 more 

Process finished with exit code 0 

這裏的調用地址不同於我的服務器存根地址。我該如何改變它? (我到處找,我找不到這樣localhost/0:0:0:0:0:0:0:1:8080代碼的地址

PLzz幫我謝謝

回答

相關問題