spring-boot-security-jwt-auth-mongodb icon indicating copy to clipboard operation
spring-boot-security-jwt-auth-mongodb copied to clipboard

way to solve "Query failed with error code 2 and error message 'Field 'locale' is invalid in: { locale: "roles" }'" exception

Open MilkSF opened this issue 3 years ago • 1 comments

If you find the following exception:

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; 
nested exception is org.springframework.data.mongodb.UncategorizedMongoDbException: 
Query failed with error code 2 and error message 'Field 'locale' is invalid in: { locale: "roles" }' 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: "roles" }' on server localhost:27017] with root cause

you can use @Document("roles") instead of @Document(collection = "roles") in Role.java, and @Document("users") instead of @Document(collection = "users") in User.java.

MilkSF avatar May 12 '22 08:05 MilkSF