use of org.springframework.boot.autoconfigure.web.HttpMessageConverters in project spring_boot by hryou0922.
the class MvcApplication method fastJsonHttpMessageConverters.
/**
* 使用fastjson做为spring mvc的json序列化
* @return
*/
@Bean
public HttpMessageConverters fastJsonHttpMessageConverters() {
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
FastJsonConfig fastJsonConfig = new FastJsonConfig();
fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);
fastConverter.setFastJsonConfig(fastJsonConfig);
HttpMessageConverter<?> converter = fastConverter;
return new HttpMessageConverters(converter);
}
use of org.springframework.boot.autoconfigure.web.HttpMessageConverters in project spring_boot by hryou0922.
the class MybatisSpringBoot method fastJsonHttpMessageConverters.
@Bean
public HttpMessageConverters fastJsonHttpMessageConverters() {
// 格式化时间
SerializeConfig mapping = new SerializeConfig();
mapping.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd HH:mm:ss"));
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
FastJsonConfig fastJsonConfig = new FastJsonConfig();
// fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);
fastJsonConfig.setSerializeConfig(mapping);
fastConverter.setFastJsonConfig(fastJsonConfig);
HttpMessageConverter<?> converter = fastConverter;
return new HttpMessageConverters(converter);
}
use of org.springframework.boot.autoconfigure.web.HttpMessageConverters in project runelite by runelite.
the class CustomConfiguration method customConverters.
@Bean
public HttpMessageConverters customConverters() {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
GsonHttpMessageConverter gsonHttpMessageConverter = new GsonHttpMessageConverter();
gsonHttpMessageConverter.setGson(gson);
// normally you can simply exclude jackson from the classpath to cause
// Spring to use gson, but minio also depends on jackson
List<HttpMessageConverter<?>> converters = new RestTemplate().getMessageConverters();
converters.removeIf(converter -> converter.getClass() == MappingJackson2HttpMessageConverter.class);
converters.add(gsonHttpMessageConverter);
return new HttpMessageConverters(false, converters);
}
use of org.springframework.boot.autoconfigure.web.HttpMessageConverters in project spring-cloud-function by spring-cloud.
the class BetterGsonHttpMessageConverter method httpMessageConverters.
@Bean
public HttpMessageConverters httpMessageConverters(Gson gson) {
List<HttpMessageConverter<?>> converters = new ArrayList<>();
for (HttpMessageConverter<?> converter : new HttpMessageConverters().getConverters()) {
if (converter instanceof GsonHttpMessageConverter) {
BetterGsonHttpMessageConverter gsonConverter = new BetterGsonHttpMessageConverter();
gsonConverter.setGson(gson);
converters.add(gsonConverter);
} else {
converters.add(converter);
}
}
return new HttpMessageConverters(false, converters);
}
Aggregations