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.core</groupId>   
    <artifactId>jackson-databind</artifactId>   
    <version>2.6.5</version>   
</dependency>   
 
<dependency>   
    <groupId>com.fasterxml.jackson.core</groupId>   
    <artifactId>jackson-core</artifactId>   
    <version>2.6.5</version>   
</dependency>   
 
<dependency>   
    <groupId>com.fasterxml.jackson.core</groupId>   
    <artifactId>jackson-annotations</artifactId>   
    <version>2.6.5</version>   
</dependency>

问题就解决了

原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/14027.html

(0)
上一篇 2021年7月19日
下一篇 2021年7月19日

相关推荐

发表回复

登录后才能评论