四时宝库

程序员的知识宝库

SpringMVC中用ResponseBody返回Json时需要手动添加jackson依赖

严重: Servlet.service() for servlet [test] in context with path [/test] threw exception [Request processing failed; nested exception is java.lang.IllegalArgumentException: No converter found for return value of type: class com.example.test.entity.User] with root cause

java.lang.IllegalArgumentException: No converter found for return value of type: class com.example.test.entity.User

使用@ResponseBody返回一个实体到页面报错!spring自家的注解还要导入第三方的jar包!

SpringMVC 中使用 @ResponseBody 返回Json时,需要手动添加jackson依赖!Maven添加:

如果你的spring版本过高,那么下面2个jar的版本也要用最新的 ,否则会抛异常

<dependency>
 <groupId>com.fasterxml.jackson.core</groupId>
 <artifactId>jackson-core</artifactId>
 <version>2.8.7</version>
</dependency>
<dependency>
 <groupId>com.fasterxml.jackson.core</groupId>
 <artifactId>jackson-databind</artifactId>
 <version>2.8.7</version>
</dependency>

实在是 恶心啊

发表评论:

控制面板
您好,欢迎到访网站!
  查看权限
网站分类
最新留言
    友情链接