Table of contents
wrong description
Use MongoDB's findOne() method to report an error:
java.lang.RuntimeException: org.springframework.data.mongodb.UncategorizedMongoDbException: Query failed with error code 2 and error message 'Field 'locale' is invalid in: { locale: "recommend_user" }' on server localhost:27017;
Solution
Check carefully, it turns out that when writing the entity class, the annotation was written wrong! !
Friends, please check it carefully!
Incorrect
@Document(collation = "recommend_user")
correct
@Document(collection = "recommend_user")
Method 1: Change collation to collection
Method 2: Or write nothing, it defaults to collection
@Document("recommend_user")
This will solve the above bug.
emm...The high probability of this error is due to the above careless operation