我一直在研究robospice-sample-spicelist
,以便将其中一部分用于我正在尝试编码的Feed阅读器。如果我按原样使用SpringAndroidSpiceService
,我会因为没有正确的消息转换器而获得异常。我意识到这个例子与Atom Feed没有任何关系,所以我用google搜索了一下,发现了AtomFeedHttpMessageConverter
。试图将其添加到服务使用的HttpMessageConverter
列表中。
public class SevillaDirectoSpringAndroidSpiceService extends SpringAndroidSpiceService {
@Override
public CacheManager createCacheManager(Application application) {
CacheManager cacheManager = new CacheManager();
JacksonObjectPersisterFactory jacksonObjectPersisterFactory = new JacksonObjectPersisterFactory(application);
cacheManager.addPersister(jacksonObjectPersisterFactory);
return cacheManager;
}
@Override
public RestTemplate createRestTemplate() {
RestTemplate restTemplate = new RestTemplate();
// find more complete examples in RoboSpice Motivation app
// to enable Gzip compression and setting request timeouts.
// web services support json responses
MappingJacksonHttpMessageConverter jsonConverter = new MappingJacksonHttpMessageConverter();
FormHttpMessageConverter formHttpMessageConverter = new FormHttpMessageConverter();
StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
AtomFeedHttpMessageConverter atomFeedHttpMessageConverter = new AtomFeedHttpMessageConverter();
final List<HttpMessageConverter<?>> listHttpMessageConverters = restTemplate.getMessageConverters();
listHttpMessageConverters.add(jsonConverter);
listHttpMessageConverters.add(formHttpMessageConverter);
listHttpMessageConverters.add(stringHttpMessageConverter);
listHttpMessageConverters.add(atomFeedHttpMessageConverter);// here I get an error marker on eclipse with the following message
restTemplate.setMessageConverters(listHttpMessageConverters);
return restTemplate;
}
}
但是当我这样做时,我收到此错误消息:
com.google.code.rome.android.repackaged.com.sun.syndication.feed.atom.Feed类型 无法解决。它是从必需的.class中间接引用的 文件
我已经尝试了robospice-sample-ui-spicelist
中找到的每个jar。我尝试使用Maven构建robospice-sample-google-http-client
,但它似乎没有“libs-for-ant”,我可以找到它所依赖的jar。