服务端报错如下:
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [org.bson.BsonUndefined] to type [java.lang.Double]] with root cause
org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [org.bson.BsonUndefined] to type [java.lang.Double]
at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:321) ~[spring-core-5.0.11.RELEASE.jar!/:5.0.11.RELEASE]
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:194) ~[spring-core-5.0.11.RELEASE.jar!/:5.0.11.RELEASE]
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:174) ~[spring-core-5.0.11.RELEASE.jar!/:5.0.11.RELEASE]
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.getPotentiallyConvertedSimpleRead(MappingMongoConverter.java:907) ~[spring-data-mongodb-2.0.12.RELEASE.jar!/:2.0.12.RELEASE]
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.readValue(MappingMongoConverter.java:1411) ~[spring-data-mongodb-2.0.12.RELEASE.jar!/:2.0.12.RELEASE]
at org.springframework.data.mongodb.core.convert.MappingMongoConverter$MongoDbPropertyValueProvider.getPropertyValue(MappingMongoConverter.java:1354) ~[spring-data-mongodb-2.0.12.RELEASE.jar!/:2.0.12.RELEASE]
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.readProperties(MappingMongoConverter.java:339) ~[spring-data-mongodb-2.0.12.RELEASE.jar!/:2.0.12.RELEASE]
................
错误信息表明Spring Framework在尝试将org.bson.BsonUndefined类型转换为java.lang.Double类型时找不到合适的转换器。
BsonUndefined类型是MongoDB驱动程序中的一个特殊类型,用于表示在数据库中未定义的字段。程序尝试读取MongoDB集合中的一个字段,而该字段在某些字段中不存在值时,MongoDB驱动可能会返回BsonUndefined。
刚才开始以为是参数对象设置问题,检查发现并没有问题,通过对上面问题的分析,检查查询条件下的MongoDB数据库数据,结果发现有个字段的值是Undefined,修改掉该字段的值问题解决。
该字段为后面新增的字段,所以历史数据没有值。