diff --git a/austin-web/src/main/java/com/java3y/austin/web/config/CommonConfiguration.java b/austin-web/src/main/java/com/java3y/austin/web/config/CommonConfiguration.java new file mode 100644 index 0000000..925ea16 --- /dev/null +++ b/austin-web/src/main/java/com/java3y/austin/web/config/CommonConfiguration.java @@ -0,0 +1,34 @@ +package com.java3y.austin.web.config; + +import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; +import com.google.common.collect.Lists; +import org.springframework.boot.autoconfigure.http.HttpMessageConverters; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; + +import java.util.List; + +/** + * @author kl + * @version 1.0.0 + * @description 通用配置 + * @date 2023/2/23 10:40 + */ +@Configuration +public class CommonConfiguration { + + /** + * FastJson 消息转换器 格式化输出json + * + * @return + */ + @Bean + public HttpMessageConverters fastJsonHttpMessageConverters() { + FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter(); + List supportedMediaTypes = Lists.newArrayList(); + supportedMediaTypes.add(MediaType.APPLICATION_JSON); + fastConverter.setSupportedMediaTypes(supportedMediaTypes); + return new HttpMessageConverters(fastConverter); + } +}