spring 4.2.4 与 Jackson 2.7 所引出的问题

今天在测试后台问题时,项目后台返回Model对象时,其实想直接得到model的json数据,但是不如人愿,报了如下的错误:

    SEVERE: Servlet.service() for servlet Spring MVC Dispatcher Servlet threw exception   
    java.lang.NoSuchMethodError: org.codehaus.jackson.map.type.TypeFactory.type(Ljava/lang/reflect/Type;)Lorg/codehaus/jackson/type/JavaType;  
    at org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.getJavaType(MappingJacksonHttpMessageConverter.java:114)  
    at org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.canRead(MappingJacksonHttpMessageConverter.java:91)  
    at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.readWithMessageConverters(HandlerMethodInvoker.java:618)  
    at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveRequestBody(HandlerMethodInvoker.java:587)  
    at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:336)  
    at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:169)  
    at   

查询官网有以下句话:

Work on Jackson 2.7 started in August 2015 and completed in early January 2016. We need to revise our type variable exposure (SPR-13728) for proper Jackson 2.7 support in Spring Framework 4.3 and should also evaluate other changes that are worth adapting to

大概的意思就是说Jackson 2.7 支持 spring 4.3 以后的版本。
那就只能降低Jackson版本了,换成了2.6.5的:

<dependency>  
    <groupId>com.fasterxml.jackson.coregroupId>  
    <artifactId>jackson-databindartifactId>  
    <version>2.6.5version>  
dependency>  

<dependency>  
    <groupId>com.fasterxml.jackson.coregroupId>  
    <artifactId>jackson-coreartifactId>  
    <version>2.6.5version>  
dependency>  

<dependency>  
    <groupId>com.fasterxml.jackson.coregroupId>  
    <artifactId>jackson-annotationsartifactId>  
    <version>2.6.5version>  
dependency>

问题就解决了

你可能感兴趣的:(spring,servlet,spring,mvc,jackson,spring,java,jackson)