Bean-validator 分组 内置了 bean-validator,需要结合 mica-boot 参数校验章节一起使用。 分组 CreateGroup DeleteGroup GetGroup UpdateGroup 使用 模型 @Datapublic class Person { private Long id; /** * 添加groups 属性,说明只在特定的验证规则里面起作用,不加则表示在使用Deafault规则时起作用 */ @NotNull(groups = {CreateGroup.class, UpdateGroup.class}) private String name; @NotNull(groups = {CreateGroup.class}) private String address; // ... ...} 方法 @PostMapping("register")public void register(@Validated(CreateGroup.class) Person person) { // ... ...} 微信 vs 公众号 精彩内容每日推荐!!!