org.springframework.boot.autoconfigure.web.HttpMessageConverters Java Examples

The following examples show how to use org.springframework.boot.autoconfigure.web.HttpMessageConverters. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FastJsonAutoConfiguration.java    From utils with Apache License 2.0 6 votes vote down vote up
@Bean
@ConditionalOnMissingBean(com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter.class)
public HttpMessageConverters customConverters(FastJsonHttpMessageConverter converter) {
    Collection<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>();

    if (null == converter) {
        Class<?> converterClass = properties.getConverter();
        converter = (FastJsonHttpMessageConverter) BeanUtils.instantiate(converterClass);
    }

    FastJsonConfig config = new FastJsonConfig();
    List<SerializerFeature> features = properties.getFeatures();
    if (!CollectionUtils.isBlank(features)) {
        SerializerFeature[] featureArray = new SerializerFeature[features.size()];
        config.setSerializerFeatures(features.toArray(featureArray));
    }

    converter.setFastJsonConfig(config);
    messageConverters.add(converter);

    return new HttpMessageConverters(true, messageConverters);
}
 
Example #2
Source File: WebConfiguration.java    From spring-cloud-dashboard with Apache License 2.0 5 votes vote down vote up
@Bean
public HttpMessageConverters messageConverters() {
	final ObjectMapper objectMapper = new ObjectMapper();
	setupObjectMapper(objectMapper);
	return new HttpMessageConverters(
			// Prevent default converters
			false,
			// Have Jackson2 converter as the sole converter
			Arrays.<HttpMessageConverter<?>>asList(new MappingJackson2HttpMessageConverter(objectMapper)));
}
 
Example #3
Source File: WebConfig.java    From easyweb with Apache License 2.0 5 votes vote down vote up
/**
 * 配置使用springmvc fastjson
 * @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);
}
 
Example #4
Source File: WebConfig.java    From jkes with Apache License 2.0 5 votes vote down vote up
@Bean
public HttpMessageConverters customConverters() {
    MappingJackson2HttpMessageConverter jsonConverter =
            new MappingJackson2HttpMessageConverter();
    jsonConverter.setSupportedMediaTypes(Arrays.asList(
            new MediaType("application", "json"),
            new MediaType("text", "json")
    ));

    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.registerModule(new JsonOrgModule());
    jsonConverter.setObjectMapper(objectMapper);
    return new HttpMessageConverters(jsonConverter);
}
 
Example #5
Source File: App.java    From SpringBoot-Study with Apache License 2.0 4 votes vote down vote up
@Bean
HttpMessageConverters fastJsonHttpMessageConverters() {
    return new HttpMessageConverters(new EncrypConverter());
}
 
Example #6
Source File: MvcConfig.java    From SkyEye with GNU General Public License v3.0 4 votes vote down vote up
@Bean
public HttpMessageConverters getJacksonHttpMessageConverters(ObjectMapper objectMapper) {
    MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(objectMapper);
    converter.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_JSON_UTF8, MediaType.TEXT_HTML, MediaType.TEXT_PLAIN));
    return new HttpMessageConverters(converter);
}
 
Example #7
Source File: AppConfig.java    From ly-security with Apache License 2.0 4 votes vote down vote up
@Bean
public HttpMessageConverters httpMessageConverters() {

    //FastJson
    return new HttpMessageConverters(fastJsonHttpMessageConverter4());
}
 
Example #8
Source File: QuotesOnDesignConfiguration.java    From cloud-native-zwitscher with MIT License 4 votes vote down vote up
@Bean
public Decoder feignDecoder() {
    HttpMessageConverter jacksonConverter = new QuoteOnDesignMessageConverter();
    ObjectFactory<HttpMessageConverters> objectFactory = () -> new HttpMessageConverters(jacksonConverter);
    return new ResponseEntityDecoder(new SpringDecoder(objectFactory));
}
 
Example #9
Source File: ResultErrorDecoder.java    From onetwo with Apache License 2.0 4 votes vote down vote up
public ResultErrorDecoder(HttpMessageConverters httpMessageConverters) {
	super();
	this.httpMessageConverters = httpMessageConverters;
}
 
Example #10
Source File: ExtResponseEntityDecoder.java    From onetwo with Apache License 2.0 4 votes vote down vote up
public ExtResponseEntityDecoder(ObjectFactory<HttpMessageConverters> messageConverter) {
	this.messageConverters = messageConverter;
}
 
Example #11
Source File: ExtSpringEncoder.java    From onetwo with Apache License 2.0 4 votes vote down vote up
public ExtSpringEncoder(ObjectFactory<HttpMessageConverters> messageConverters) {
	super(messageConverters);
	/*getParamsConvertor.setPropertyAcceptor((prop, value)->{
		return true;
	});*/
}