【发布时间】:2018-10-14 11:57:50
【问题描述】:
我正在使用带有 Spring Boot 2.0.1.RELEASE 的 MongoDB。一切似乎都运行良好。我能够使用 MongoRepository 正确执行 CRUD 操作。当我在
@Query(value = "{address.city:?0}")
public List<Hotel> findByCity(String city);
@Query(value = "{address.country:?0}")
public List<Hotel> findByCountry(String country);
当我尝试使用 url localhost:8090/hotels/address/city/Rome 访问数据时,我收到以下错误响应
{
"timestamp": "2018-05-04T04:51:43.549+0000",
"status": 500,
"error": "Internal Server Error",
"message": "Invalid JSON input. Position: 9. Character: '.'.",
"path": "/hotels/address/city/rome"
}
和以下登录控制台:
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.bson.json.JsonParseException: Invalid JSON input. Position: 9. Character: '.'.] with root cause
org.bson.json.JsonParseException: Invalid JSON input. Position: 9. Character: '.'.
我不知道为什么我在执行GET 请求时收到Invalid JSON input. Position: 9. Character: '.'.?
我哪里错了?
【问题讨论】:
-
缺少引号;
@Query(value = "{'address.country':?0}") -
谢谢!!!这解决了我的问题。
标签: spring mongodb spring-boot spring-mongodb mongorepository