1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 【Spring】HttpMessageNotWritableException No converter found for return value of type

【Spring】HttpMessageNotWritableException No converter found for return value of type

时间:2019-06-26 05:50:48

相关推荐

【Spring】HttpMessageNotWritableException No converter found for return value of type

1.背景

Spring boot 启动报错

Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableException: No converter found for return value of type: class java.util.LinkedHashMap

出现以上错误,原因在于,缺少了springmvc进行json转换需要的jar包,引入对应jar依赖:

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

另外在pom文件中如果引入springboot-web依赖排除掉了springboot-web自带的json也会导致上面的异常信息:

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><exclusions><exclusion><artifactId>spring-boot-starter-json</artifactId><groupId>org.springframework.boot</groupId></exclusion></exclusions></dependency>

此时,需要将依赖改为以下即可:

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency>

/cnd2449294059/article/details/104216291

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。