IDEA创建MongoDB的实体出现的低级错误
1.错误内容如下
org.springframework.data.mongodb.UncategorizedMongoDbException: Query failed with error code 2 and error message 'Field 'locale' is invalid in: { locale: "comment" }' on server localhost:27017; nested exception is com.mongodb.MongoQueryException: Query failed with error code 2 and error message 'Field 'locale' is invalid in: { locale: "comment" }' on server localhost:27017
原先出错的代码
正确的代码
分析如下:
报错原因(巨坑):@Document
使用collation
属性指定了某个集合,实际上应该是collection
,他们俩个名字很像,很容易弄错!
巨大的坑!!!!!!