java.lang.IllegalArgumentException:找不到类型返回值的转换器 [英] java.lang.IllegalArgumentException: No converter found for return value of type
本文介绍了java.lang.IllegalArgumentException:找不到类型返回值的转换器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用此代码
@RequestMapping(value = "/bar/foo", method = RequestMethod.GET)
public ResponseEntity<foo> foo() {
Foo model;
...
return ResponseEntity.ok(model);
}
}
我收到以下异常
java.lang.IllegalArgumentException: No converter found for return value of type
我的猜测是,由于杰克逊失踪,该对象无法转换为JSON。我不明白为什么,因为我认为杰克逊是用弹簧靴内置的。
My guess is that the object cannot be converted to JSON because Jackson is missing. I don't understand why because I thought that Jackson was built in with spring boot.
然后我试图将Jackson添加到pom.xml但我还是有相同的错误
Then I have tried to add Jackson to the pom.xml but I still have the same error
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.4.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.4.3</version>
</dependency>
我是否必须更改任何弹簧启动属性才能使其正常工作?
Do I have to change any spring boot properties to make this work?
谢谢
推荐答案
问题是Foo中的一个嵌套对象没有任何 getter / setter
The problem was that one of the nested objects in Foo didn't have any getter/setter
这篇关于java.lang.IllegalArgumentException:找不到类型返回值的转换器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文