diff --git a/src/main/java/top/angelinaBot/config/AngelinaMappingJackson2HttpMessageConverter.java b/src/main/java/top/angelinaBot/config/AngelinaMappingJackson2HttpMessageConverter.java new file mode 100644 index 0000000..b61ca02 --- /dev/null +++ b/src/main/java/top/angelinaBot/config/AngelinaMappingJackson2HttpMessageConverter.java @@ -0,0 +1,17 @@ +package top.angelinaBot.config; + +import org.springframework.http.MediaType; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; + +import java.util.ArrayList; +import java.util.List; + +public class AngelinaMappingJackson2HttpMessageConverter extends MappingJackson2HttpMessageConverter { + + public AngelinaMappingJackson2HttpMessageConverter(){ + List mediaTypes = new ArrayList<>(); + mediaTypes.add(MediaType.TEXT_PLAIN); + mediaTypes.add(MediaType.TEXT_HTML); + setSupportedMediaTypes(mediaTypes); + } +} diff --git a/src/main/java/top/angelinaBot/config/RestTemplateConfig.java b/src/main/java/top/angelinaBot/config/RestTemplateConfig.java new file mode 100644 index 0000000..1616ed6 --- /dev/null +++ b/src/main/java/top/angelinaBot/config/RestTemplateConfig.java @@ -0,0 +1,15 @@ +package top.angelinaBot.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.client.RestTemplate; + +@Configuration +public class RestTemplateConfig { + @Bean("restTemplate") + public RestTemplate restTemplate() { + RestTemplate restTemplate = new RestTemplate(); + restTemplate.getMessageConverters().add(new AngelinaMappingJackson2HttpMessageConverter()); + return restTemplate; + } +}