spring-boot-security-jwt-auth-mongodb
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
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.