我正在尝试使用Spring RestTemplate
来检索员工记录列表,例如:
public List<Employee> getEmployeesByFirstName(String firstName) {
return restTemplate.getForObject(employeeServiceUrl + "/firstname/{firstName}", List.class, firstName);
}
问题是 Web 服务(被调用)返回以下 XML 格式:
<雇员> <雇员> .... </雇员> <雇员> .... </雇员> </雇员>
因此,在执行上述方法时,出现以下错误:
org.springframework.http.converter.HttpMessageNotReadableException: Could not read [interface java.util.List]; nested exception is org.springframework.oxm.UnmarshallingFailureException: XStream unmarshalling exception; nested exception is com.thoughtworks.xstream.mapper.CannotResolveClassException: **employees : employees**