spring4.x之HttpMessageConverter

public class WebMvcConfigurationSupport implements ApplicationContextAware, ServletContextAware {
    private static boolean romePresent = ClassUtils.isPresent("com.rometools.rome.feed.WireFeed", WebMvcConfigurationSupport.class.getClassLoader());
    private static final boolean jaxb2Present = ClassUtils.isPresent("javax.xml.bind.Binder", WebMvcConfigurationSupport.class.getClassLoader());
    private static final boolean jackson2Present = ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", WebMvcConfigurationSupport.class.getClassLoader()) && ClassUtils.isPresent("com.fasterxml.jackson.core.JsonGenerator", WebMvcConfigurationSupport.class.getClassLoader());
    private static final boolean jackson2XmlPresent = ClassUtils.isPresent("com.fasterxml.jackson.dataformat.xml.XmlMapper", WebMvcConfigurationSupport.class.getClassLoader());
    private static final boolean gsonPresent = ClassUtils.isPresent("com.google.gson.Gson", WebMvcConfigurationSupport.class.getClassLoader());

spring内部已经内置了,feed,json,protobuf的支持,只要在pom.xml的配置文件中添加相应的库支持,即可。



   com.fasterxml.jackson.core
   jackson-core
   ${jackson.version}


   com.fasterxml.jackson.core
   jackson-databind
   ${jackson.version}



 com.google.protobuf
 protobuf-java
 2.5.0


 com.googlecode.protobuf-java-format
 protobuf-java-format
 1.2