package de.dfki.nlp.config; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.Lists; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.converter.StringHttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter; import org.springframework.web.client.RestTemplate; @Configuration public class GeneralConfig { @Bean RestTemplate restTemplate(ObjectMapper objectMapper) { RestTemplate restTemplate = new RestTemplate(); restTemplate.setMessageConverters(Lists.newArrayList( jaxb2RootElementHttpMessageConverter(), new StringHttpMessageConverter(), new MappingJackson2HttpMessageConverter(objectMapper))); return restTemplate; } @Bean Jaxb2RootElementHttpMessageConverter jaxb2RootElementHttpMessageConverter() { Jaxb2RootElementHttpMessageConverter jaxb2RootElementHttpMessageConverter = new Jaxb2RootElementHttpMessageConverter(); jaxb2RootElementHttpMessageConverter.setSupportDtd(true); return jaxb2RootElementHttpMessageConverter; } }