com.fasterxml.jackson.databind.JsonMappingException: 数值 (1557587751202) 超出 int 范围
com.fasterxml.jackson.databind.JsonMappingException: Numeric value (1557587751202) out of range of int
我使用 Spring Initializr 生成了 Spring Boot web 应用程序,在 macOS Sierra 中使用嵌入式 Tomcat + Thymeleaf 模板引擎,我必须在其中解析 Json对象
我有一个域对象 属性:
@JsonProperty("activationTime")
private BigInteger activationTime;
但是当我解析对象时出现这个错误:
com.fasterxml.jackson.databind.JsonMappingException: Numeric value (1557587751202) out of range of int
at [Source: {"data":[{"id":"18AE62","name":"Device 0018AE62","type":"59147fd79e93a12e61499ffe","last":1515409036,"averageSignal":41.35125,"averageSnr":41.35125,"averageRssi":-109.87788,"state":0,"activationTime":1494515751202,"lat":0.0,"lng":0.0,"tokenType":"CONTRACT","contractId":"58d2956f3c87892877423fa3","tokenEnd":1557587751202,"preventRenewal":true,"automaticRenewal":false}],"paging":{}}; line: 1, column: 322]
at [Source: {"data":[{"id":"18AE62","name":"Device 0018AE62","type":"59147fd79e93a12e61499ffe","last":1515409036,"averageSignal":41.35125,"averageSnr":41.35125,"averageRssi":-109.87788,"state":0,"activationTime":1494515751202,"lat":0.0,"lng":0.0,"tokenType":"CONTRACT","contractId":"58d2956f3c87892877423fa3","tokenEnd":1557587751202,"preventRenewal":true,"automaticRenewal":false}],"paging":{}}; line: 1, column: 309] (through reference chain: com.ideefecloud.backend.sigfox.domain.backend.DevicesForAGivenDeviceType["data"]->java.util.ArrayList[0]->com.ideefecloud.backend.sigfox.domain.backend.Datum["tokenEnd"])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:388)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:348)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.wrapAndThrow(BeanDeserializerBase.java:1611)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:278)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:140)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:287)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:259)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:26)
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:504)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:104)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:276)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:140)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3814)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2858)
at com.laberint.backend.service.SigfoxRestApiService.getDevicesForAGivenDeviceTypeDeviceType(SigfoxRestApiService.java:105)
at com.laberint.backend.service.SigfoxRestApiServiceTests.testGetAddressFromCoordinates(SigfoxRestApiServiceTests.java:50)
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.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.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access[=12=]0(ParentRunner.java:58)
at org.junit.runners.ParentRunner.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.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:539)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:761)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:461)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:207)
Caused by: com.fasterxml.jackson.core.JsonParseException: Numeric value (1557587751202) out of range of int
at [Source: {"data":[{"id":"18AE62","name":"Device 0018AE62","type":"59147fd79e93a12e61499ffe","last":1515409036,"averageSignal":41.35125,"averageSnr":41.35125,"averageRssi":-109.87788,"state":0,"activationTime":1494515751202,"lat":0.0,"lng":0.0,"tokenType":"CONTRACT","contractId":"58d2956f3c87892877423fa3","tokenEnd":1557587751202,"preventRenewal":true,"automaticRenewal":false}],"paging":{}}; line: 1, column: 322]
at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1702)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:558)
at com.fasterxml.jackson.core.base.ParserBase.convertNumberToInt(ParserBase.java:928)
at com.fasterxml.jackson.core.base.ParserBase._parseIntValue(ParserBase.java:866)
at com.fasterxml.jackson.core.base.ParserBase.getIntValue(ParserBase.java:694)
at com.fasterxml.jackson.databind.deser.std.NumberDeserializers$IntegerDeserializer.deserialize(NumberDeserializers.java:299)
at com.fasterxml.jackson.databind.deser.std.NumberDeserializers$IntegerDeserializer.deserialize(NumberDeserializers.java:279)
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:504)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:104)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:276)
... 41 more
"tokenEnd":1557587751202
那是你的问题。 java 中的 int
的最大值为 2,147,483,647。将代表 tokenEnd
的任何 class 字段更改为(例如)long
.
我使用 Spring Initializr 生成了 Spring Boot web 应用程序,在 macOS Sierra 中使用嵌入式 Tomcat + Thymeleaf 模板引擎,我必须在其中解析 Json对象
我有一个域对象 属性:
@JsonProperty("activationTime")
private BigInteger activationTime;
但是当我解析对象时出现这个错误:
com.fasterxml.jackson.databind.JsonMappingException: Numeric value (1557587751202) out of range of int
at [Source: {"data":[{"id":"18AE62","name":"Device 0018AE62","type":"59147fd79e93a12e61499ffe","last":1515409036,"averageSignal":41.35125,"averageSnr":41.35125,"averageRssi":-109.87788,"state":0,"activationTime":1494515751202,"lat":0.0,"lng":0.0,"tokenType":"CONTRACT","contractId":"58d2956f3c87892877423fa3","tokenEnd":1557587751202,"preventRenewal":true,"automaticRenewal":false}],"paging":{}}; line: 1, column: 322]
at [Source: {"data":[{"id":"18AE62","name":"Device 0018AE62","type":"59147fd79e93a12e61499ffe","last":1515409036,"averageSignal":41.35125,"averageSnr":41.35125,"averageRssi":-109.87788,"state":0,"activationTime":1494515751202,"lat":0.0,"lng":0.0,"tokenType":"CONTRACT","contractId":"58d2956f3c87892877423fa3","tokenEnd":1557587751202,"preventRenewal":true,"automaticRenewal":false}],"paging":{}}; line: 1, column: 309] (through reference chain: com.ideefecloud.backend.sigfox.domain.backend.DevicesForAGivenDeviceType["data"]->java.util.ArrayList[0]->com.ideefecloud.backend.sigfox.domain.backend.Datum["tokenEnd"])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:388)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:348)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.wrapAndThrow(BeanDeserializerBase.java:1611)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:278)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:140)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:287)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:259)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:26)
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:504)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:104)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:276)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:140)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3814)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2858)
at com.laberint.backend.service.SigfoxRestApiService.getDevicesForAGivenDeviceTypeDeviceType(SigfoxRestApiService.java:105)
at com.laberint.backend.service.SigfoxRestApiServiceTests.testGetAddressFromCoordinates(SigfoxRestApiServiceTests.java:50)
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.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.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access[=12=]0(ParentRunner.java:58)
at org.junit.runners.ParentRunner.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.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:539)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:761)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:461)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:207)
Caused by: com.fasterxml.jackson.core.JsonParseException: Numeric value (1557587751202) out of range of int
at [Source: {"data":[{"id":"18AE62","name":"Device 0018AE62","type":"59147fd79e93a12e61499ffe","last":1515409036,"averageSignal":41.35125,"averageSnr":41.35125,"averageRssi":-109.87788,"state":0,"activationTime":1494515751202,"lat":0.0,"lng":0.0,"tokenType":"CONTRACT","contractId":"58d2956f3c87892877423fa3","tokenEnd":1557587751202,"preventRenewal":true,"automaticRenewal":false}],"paging":{}}; line: 1, column: 322]
at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1702)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:558)
at com.fasterxml.jackson.core.base.ParserBase.convertNumberToInt(ParserBase.java:928)
at com.fasterxml.jackson.core.base.ParserBase._parseIntValue(ParserBase.java:866)
at com.fasterxml.jackson.core.base.ParserBase.getIntValue(ParserBase.java:694)
at com.fasterxml.jackson.databind.deser.std.NumberDeserializers$IntegerDeserializer.deserialize(NumberDeserializers.java:299)
at com.fasterxml.jackson.databind.deser.std.NumberDeserializers$IntegerDeserializer.deserialize(NumberDeserializers.java:279)
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:504)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:104)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:276)
... 41 more
"tokenEnd":1557587751202
那是你的问题。 java 中的 int
的最大值为 2,147,483,647。将代表 tokenEnd
的任何 class 字段更改为(例如)long
.