Validated 对方法的校验

针对InfoDTO注解进行校验

InfoDTO dto = new InfoDTO();
BeanUtils.copyProperties(ncInfoDTO, dto);
ObjectUtil.notNullCheck(dto);

/**
 * @auther: 12778 2023/3/29 09:38
 * @description:
 */
@Data
public class InfoDTO implements Serializable {

    private static final long serialVersionUID = -1041305958968468564L;


    /**
     * 姓名
     */
    @NotBlank(message = "姓名不能为空")
    private String name;
}


import org.springframework.util.ObjectUtils;
import org.springframework.util.ReflectionUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * @auther: 12778 2023/3/29 10:40
 * @description:
 */
public class Object

你可能感兴趣的:(java,开发语言,jvm)