Could not read document: Can not deserialize instance of java.lang.xxx out of START_OBJECT token
来源:互联网 发布:917发卡软件 编辑:程序博客网 时间:2024/04/29 13:03
Java 项目中遇到的问题:Could not read document: Can not deserialize instance of java.lang.String out of START_OBJECT token
前些日子在项目中遇到这样一个问题,调用一个方法时报错,特意记录下。
下面是控制台输出信息:
org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Can not deserialize instance of java.lang.String out of START_OBJECT token at [Source: java.io.PushbackInputStream@33b082c5; line: 1, column: 1]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.String out of START_OBJECT token at [Source: java.io.PushbackInputStream@33b082c5; line: 1, column: 1] at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:240) at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.read(AbstractJackson2HttpMessageConverter.java:225) at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:95) at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:917) at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:901) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:655) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:613) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:531) at com.einwin.jd.utils.JDRequestUtil.postForEntityWithOutToken(JDRequestUtil.java:91) at com.einwin.jd.utils.JDRequestUtil.postForEntity(JDRequestUtil.java:61) at com.einwin.jd.utils.JDRequestUtil.postForEntity(JDRequestUtil.java:36) at com.einwin.jd.client.OrderClient.comfirmReceipt(OrderClient.java:253) at com.einwin.test.OrderTest.comfirmReceipt(OrderTest.java:223) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.String out of START_OBJECT token...
由消息日志可以看出,它报了HttpMessageNotReadableException消息不可读异常和JsonMappingException JSON映射异常,由此知是由于JSON映射不一致而导致HttpMessageNotReadableException
一般情况下是由于你请求回来的数据是json类型,而你用来接收的参数类型不是json类型造成的。或者是其他返回参数和接收参数不一致造成的,仔细检查代码,改为一致即可。
阅读全文
0 0
- Could not read document: Can not deserialize instance of java.lang.xxx out of START_OBJECT token
- Could not read JSON: Can not deserialize instance of java.lang.Integer out of START_OBJECT token
- Could not read JSON: Can not deserialize instance of java.lang.String out of START_OBJECT token
- Could not read JSON: Can not deserialize instance of java.lang.String[] out of VALUE_STRING token
- Can not deserialize instance of java.lang.String out of START_OBJECT token
- Can not deserialize instance of java.lang.String out of START_OBJECT token
- 关于接收List报Can not deserialize instance of java.util.ArrayList out of START_OBJECT token
- Could not read JSON: Can not deserialize instance of out of START_ARRAY token
- Cannot deserialize instance of java.lang.String out of START_ARRAY/START_OBJECT token,RestTemplate小坑
- Can not deserialize instance of java.util.ArrayList out of VALUE_FALSE token
- Unexpected error during response processing Can not deserialize instance of java.lang.String out of
- com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize out of START_ARRAY token
- org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.ArrayList o
- 关于fasterxml-jackson发生Can not deserialize instance of异常原因验证
- The document "X.xib" could not be opened. Could not read archive. Please use a newer version of Xco
- java.lang.IllegalStateException: Could not execute method of the activity
- java.lang.IllegalStateException: Could not execute method of the activity
- java.lang.IllegalStateException: Could not execute method of the activity
- 深入理解python中的生成器
- 复数乘法运算(三次实数乘法)-c++代码实现
- Web前端学习路线
- Mybatis
- mysql知识整理
- Could not read document: Can not deserialize instance of java.lang.xxx out of START_OBJECT token
- [运维]Can't init tc log
- 简单的桶排序(个人练习算法)
- iOS使用MBProgressHUD出现的坑
- 使用ZXing实现二维码扫描
- Android进阶-Android 5.X 的新特性
- 在执行Maven Projects下的clean以及compile命令时不再支持源选项 1.5。请使用 1.6 或更高版本。
- JAVA SE — Day 19
- JavaScript中的数据类型