no suitable constructor found, can not deserialize from Object value (missing default constructor or

来源:互联网 发布:悲伤的网络歌曲 编辑:程序博客网 时间:2024/05/22 02:09

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,所以我加入了无参构造,都加,然后重新运行请求,正常!

0 0
原创粉丝点击