本文主要是介绍no suitable constructor found, can not deserialize from Object value (missing default constructor or,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
spring cloud 运行中,启动了provider,再启动了consumer,然后在consumer中向provider发送请求报错:
2017-04-27 09:34:23.234 WARN 2176 --- [nio-7900-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Can not construct instance of com.sino.cloud.entity.User: no suitable constructor found, can not deserialize from Object value (missing default constructor or creator, or perhaps need to add/enable type information?)
at [Source: java.io.PushbackInputStream@5f26848a; line: 1, column: 3] (through reference chain: java.lang.Object[][0]);
这个错误的起源是因为我做测试,没有使用数据库,在findAll()方法里直接循环new的user对象,所以报错找不到合适的user对象的构造,这是检查我的user类中,我是有含参构造,然后由于错误是400,所以我加入了无参构造,都加,然后重新运行请求,正常!
这篇关于no suitable constructor found, can not deserialize from Object value (missing default constructor or的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!