当前位置: 首页>>代码示例>>Java>>正文


Java HttpMessageConverters类代码示例

本文整理汇总了Java中org.springframework.boot.autoconfigure.web.HttpMessageConverters的典型用法代码示例。如果您正苦于以下问题:Java HttpMessageConverters类的具体用法?Java HttpMessageConverters怎么用?Java HttpMessageConverters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HttpMessageConverters类属于org.springframework.boot.autoconfigure.web包,在下文中一共展示了HttpMessageConverters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: wxApiTemplate

import org.springframework.boot.autoconfigure.web.HttpMessageConverters; //导入依赖的package包/类
/**
 * 是否有必要模仿Spring不提供RestTemplate,只提供RestTemplateBuilder
 *
 * @return dummy
 */
@Bean(name = WxBeans.WX_API_TEMPLATE_NAME)
public WxApiTemplate wxApiTemplate() {
    RestTemplateBuilder builder = new RestTemplateBuilder();
    builder = builder.requestFactory(new WxApiHttpRequestFactory(wxProperties))
            .errorHandler(new WxResponseErrorHandler());
    HttpMessageConverters converters = this.messageConverters.getIfUnique();
    List<HttpMessageConverter<?>> converterList = new ArrayList<>();
    // 加入默认转换
    converterList.add(new WxHttpInputMessageConverter());
    if (converters != null) {
        converterList.addAll(converters.getConverters());
        builder = builder.messageConverters(Collections.unmodifiableList(converterList));
    }
    return new WxApiTemplate(builder.build());
}
 
开发者ID:FastBootWeixin,项目名称:FastBootWeixin,代码行数:21,代码来源:WxInvokerConfiguration.java

示例2: feignDecoder

import org.springframework.boot.autoconfigure.web.HttpMessageConverters; //导入依赖的package包/类
@Bean
public Decoder feignDecoder () {
    val springConverters = messageConverters.getObject().getConverters();
    val decoderConverters = new ArrayList<HttpMessageConverter<?>>(springConverters.size() + 1);

    decoderConverters.addAll(springConverters);
    decoderConverters.add(new SpringManyMultipartFilesReader(4096));

    val httpMessageConverters = new HttpMessageConverters(decoderConverters);

    return new SpringDecoder(new ObjectFactory<HttpMessageConverters>() {

        @Override
        public HttpMessageConverters getObject () {
            return httpMessageConverters;
        }
    });
}
 
开发者ID:OpenFeign,项目名称:feign-form,代码行数:19,代码来源:DownloadClient.java

示例3: customConverters

import org.springframework.boot.autoconfigure.web.HttpMessageConverters; //导入依赖的package包/类
@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);
}
 
开发者ID:storezhang,项目名称:utils,代码行数:23,代码来源:FastJsonAutoConfiguration.java

示例4: customConverters

import org.springframework.boot.autoconfigure.web.HttpMessageConverters; //导入依赖的package包/类
@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);
}
 
开发者ID:runelite,项目名称:runelite,代码行数:19,代码来源:CustomConfiguration.java

示例5: registerHttpMessageConverters

import org.springframework.boot.autoconfigure.web.HttpMessageConverters; //导入依赖的package包/类
private String registerHttpMessageConverters(final String id) {
    return registry.register(id, HttpMessageConverters.class, () -> {
        final List<Object> list = list();

        LOG.debug("Client [{}]: Registering StringHttpMessageConverter", id);
        list.add(genericBeanDefinition(StringHttpMessageConverter.class)
                .addPropertyValue("writeAcceptCharset", false)
                .getBeanDefinition());

        final String objectMapperId = findObjectMapper(id);

        LOG.debug("Client [{}]: Registering MappingJackson2HttpMessageConverter referencing [{}]", id, objectMapperId);
        list.add(genericBeanDefinition(MappingJackson2HttpMessageConverter.class)
                .addConstructorArgReference(objectMapperId)
                .getBeanDefinition());

        LOG.debug("Client [{}]: Registering StreamConverter referencing [{}]", id, objectMapperId);
        list.add(genericBeanDefinition(Streams.class)
                .setFactoryMethod("streamConverter")
                .addConstructorArgReference(objectMapperId)
                .getBeanDefinition());

        return BeanDefinitionBuilder.genericBeanDefinition(ClientHttpMessageConverters.class)
                .addConstructorArgValue(list);
    });
}
 
开发者ID:zalando-stups,项目名称:put-it-to-rest,代码行数:27,代码来源:RestClientPostProcessor.java

示例6: messageConverters

import org.springframework.boot.autoconfigure.web.HttpMessageConverters; //导入依赖的package包/类
@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)));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:11,代码来源:WebConfiguration.java

示例7: fastJsonHttpMessageConverters

import org.springframework.boot.autoconfigure.web.HttpMessageConverters; //导入依赖的package包/类
/**
 * 配置使用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);
}
 
开发者ID:egojit8,项目名称:easyweb,代码行数:14,代码来源:WebConfig.java

示例8: fastJsonHttpMessageConverters

import org.springframework.boot.autoconfigure.web.HttpMessageConverters; //导入依赖的package包/类
@Bean
public HttpMessageConverters fastJsonHttpMessageConverters() {
    FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
    //处理中文乱码
    List<MediaType> fastMediaTypes = new ArrayList<>();
    fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
    fastConverter.setSupportedMediaTypes(fastMediaTypes);
    return new HttpMessageConverters((HttpMessageConverter<?>) fastConverter);
}
 
开发者ID:DomKing,项目名称:springbootWeb,代码行数:10,代码来源:MessageConverterConfig.java

示例9: customConverters

import org.springframework.boot.autoconfigure.web.HttpMessageConverters; //导入依赖的package包/类
@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);
}
 
开发者ID:chaokunyang,项目名称:jkes,代码行数:15,代码来源:WebConfig.java

示例10: messageConverters

import org.springframework.boot.autoconfigure.web.HttpMessageConverters; //导入依赖的package包/类
@Bean
public HttpMessageConverters messageConverters() {
  GsonHttpMessageConverter gsonHttpMessageConverter = new GsonHttpMessageConverter();
  gsonHttpMessageConverter.setGson(
          new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").create());
  final List<HttpMessageConverter<?>> converters = Lists.newArrayList(
          new ByteArrayHttpMessageConverter(), new StringHttpMessageConverter(),
          new AllEncompassingFormHttpMessageConverter(), gsonHttpMessageConverter);
  return new HttpMessageConverters() {
    @Override
    public List<HttpMessageConverter<?>> getConverters() {
      return converters;
    }
  };
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:16,代码来源:HttpMessageConverterConfiguration.java

示例11: getDefaultWxMessageConverters

import org.springframework.boot.autoconfigure.web.HttpMessageConverters; //导入依赖的package包/类
/**
 * 只考虑微信的消息转换,后期可以优化
 * 其实这里完全可以使用系统的Bean,但是这里我想特殊处理,只对微信消息做转换,所以定制化了几个converter
 *
 * @return dummy
 */
private HttpMessageConverters getDefaultWxMessageConverters() {
    StringHttpMessageConverter stringConverter = new StringHttpMessageConverter(StandardCharsets.UTF_8);
    stringConverter.setWriteAcceptCharset(false);
    MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
    Jaxb2RootElementHttpMessageConverter xmlConverter = new Jaxb2RootElementHttpMessageConverter();
    AllEncompassingFormHttpMessageConverter formConverter = new AllEncompassingFormHttpMessageConverter();
    ResourceHttpMessageConverter resourceConverter = new ResourceHttpMessageConverter();
    HttpMessageConverters wxMessageConverters = new HttpMessageConverters(stringConverter, jsonConverter, xmlConverter, formConverter, resourceConverter);
    return wxMessageConverters;
}
 
开发者ID:FastBootWeixin,项目名称:FastBootWeixin,代码行数:17,代码来源:WxInvokerConfiguration.java

示例12: customConverters

import org.springframework.boot.autoconfigure.web.HttpMessageConverters; //导入依赖的package包/类
@Bean
public HttpMessageConverters customConverters() {
  List<HttpMessageConverter<?>> converters = new ArrayList<>();

  converters.add(new FunctionalSyntaxHttpMessageConverter());
  converters.add(new ManchesterSyntaxHttpMessageConverter());
  converters.add(new OwlXmlHttpMessageConverter());
  converters.add(new RdfXmlOntologyHttpMessageConverter());
  converters.add(new TurtleOntologyHttpMessageConverter());

  return new HttpMessageConverters(converters);
}
 
开发者ID:VisualDataWeb,项目名称:OntoBench,代码行数:13,代码来源:WebMvcConfig.java

示例13: compensableFeignDecoder

import org.springframework.boot.autoconfigure.web.HttpMessageConverters; //导入依赖的package包/类
@org.springframework.context.annotation.Primary
@org.springframework.context.annotation.Bean
public feign.codec.Decoder compensableFeignDecoder(@Autowired feign.codec.Decoder decoder,
		@Autowired ObjectFactory<HttpMessageConverters> objectFactory) {
	CompensableFeignDecoder feignDecoder = new CompensableFeignDecoder(decoder);
	feignDecoder.setObjectFactory(objectFactory);
	return feignDecoder;
}
 
开发者ID:liuyangming,项目名称:ByteTCC,代码行数:9,代码来源:SpringCloudBackupConfiguration.java

示例14: compensableFeignDecoder

import org.springframework.boot.autoconfigure.web.HttpMessageConverters; //导入依赖的package包/类
@org.springframework.context.annotation.Primary
@org.springframework.context.annotation.Bean
public feign.codec.Decoder compensableFeignDecoder(@Autowired ObjectFactory<HttpMessageConverters> objectFactory) {
	CompensableFeignDecoder feignDecoder = new CompensableFeignDecoder();
	feignDecoder.setObjectFactory(objectFactory);
	return feignDecoder;
}
 
开发者ID:liuyangming,项目名称:ByteTCC,代码行数:8,代码来源:SpringCloudConfiguration.java

示例15: messageConverters

import org.springframework.boot.autoconfigure.web.HttpMessageConverters; //导入依赖的package包/类
@Bean
public HttpMessageConverters messageConverters(ObjectMapper objectMapper) {
	return new HttpMessageConverters(
			// Prevent default converters
			false,
			// Have Jackson2 converter as the sole converter
			Arrays.<HttpMessageConverter<?>>asList(new MappingJackson2HttpMessageConverter(objectMapper)));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:9,代码来源:WebConfiguration.java


注:本文中的org.springframework.boot.autoconfigure.web.HttpMessageConverters类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。