【Spring】No converter found for return value of type: class java.util.ArrayList

错误信息:

org.springframework.http.converter.HttpMessageNotWritableException: No converter found for return value of type: class java.util.ArrayList

如图所示:

http://www.cnblogs.com/hafiz/p/5812873.html 提供了一种解决方案,似乎也是很多人的做法,但我试过之后发现不行。

后来发现是版本的问题:升了 jackson 版本后解决。
PS: 又添加了 jackson-annotations 依赖,如下:

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.version}</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>${jackson.version}</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>${jackson.version}</version>
        </dependency>

————————————————————
初始版本信息:
Spring: 5.0.7.RELEASE
jackson: 2.8.11

更改之后版本信息:
Spring: 5.0.7.RELEASE
jackson: 2.9.5

猜你喜欢

转载自www.cnblogs.com/jaxer/p/9611118.html