Reputation: 13
I tried to use the @Indexed(unique=true) annotation at my entity but it never throw an error for a duplicate value. The @postmapping is working good but no validation error.
Code Link: https://github.com/kuyabooo/reactiveMongoUniqueValidation.git User Entity Image
Upvotes: 0
Views: 562
Reputation: 21
Do the fallowing Changes in Code
add fallowing property
spring.data.mongodb.auto-index-creation= true
you always need to specify the name of Index before creating so change syntax of @Indexed
@Indexed(name = "pratik_dandre_index",unique = true)
NOTE : you should use any name for @Indexed
Upvotes: 1