如何在Android中使用RestClientException catch

CSS*_*SSG 3 java rest spring

我有一个Rest Web服务,我从下面的android代码中使用这个Web服务.

Web服务工作正常我已经测试过了.

但是在下面的代码中我得到了错误

  String url ="http://10.0.2.2:29512/Restweb_2/webresources/generic/shirish";

  RestTemplate resttemplate = new RestTemplate();
    Log.v("in1", "in1");
 resttemplate.getMessageConverters().add(new StringHttpMessageConverter());
    Log.v("in2", "in2");
   String result;
        try {            
            result = resttemplate.getForObject(url,String.class);
        } 
        catch (RestClientException ex) {
           ![I am getting this error while using this exception and I am not able to proceed further if I don't use this exception(Or it is giving me error in result assign statment)][1]. So how to use RestClient!Exception ????? Also I already import the needed jar files.

        }
Run Code Online (Sandbox Code Playgroud)

Ash*_*eyJ 5

不兼容的类型需要throwable找到RestClientException

当你包含spring-android-rest-template-xxxx.jar并且没有包含spring-android-core-xxxx.jar时,可能会导致这种情况