【问题标题】:Spring boot Webflux(Reactive MongoDb) Unique ValidationSpring boot Webflux(Reactive MongoDb) 唯一验证
【发布时间】:2020-12-10 02:03:21
【问题描述】:

我尝试在我的实体上使用 @Indexed(unique=true) 注释,但它从不会对重复值抛出错误。 @postmapping 运行良好,但没有验证错误。

代码链接:https://github.com/kuyabooo/reactiveMongoUniqueValidation.git User Entity Image

【问题讨论】:

    标签: spring-webflux


    【解决方案1】:

    在代码中进行随意的更改

    1. 添加休闲财产
      spring.data.mongodb.auto-index-creation=true

    2. 您总是需要在创建之前指定 Index 的名称,因此请更改 @Indexed
      的语法 @Indexed(name = "pratik_dandre_index",unique = true)

    注意:您应该为 @Indexed

    使用任何名称

    【讨论】:

      猜你喜欢
      • 2020-01-29
      • 2021-05-10
      • 2022-01-14
      • 1970-01-01
      • 2021-05-03
      • 2018-02-07
      • 2022-01-01
      • 2019-08-15
      • 2021-02-25
      相关资源
      最近更新 更多