TaleLin / lin-cms-spring-boot

🔨 基于SpringBoot的CMS/DMS/管理系统开发框架
http://doc.cms.talelin.com/
MIT License
904 stars 253 forks source link

DTO验证只有一个字段的时候有bug #210

Closed nine-city closed 3 years ago

nine-city commented 3 years ago

拉取的Lin CMS最新代码。 代码如下 @PostMapping("/qq/login") public String appLogin(@Validated @RequestBody QQLoginDTO loginDTO) { return "aaa"; }

` @Data @NoArgsConstructor public class QQLoginDTO {

@NotBlank(message = "{code.not-blank}")
private String code;

} `

如果code参数没传,返回给前端没有任何提示信息 { "code": 10030, "message": "", "request": "POST /user/qq/login" }

报错信息 org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot construct instance of io.github.talelin.latticy.dto.user.AppLoginDTO (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of io.github.talelin.latticy.dto.user.AppLoginDTO (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator)

好像是因为只有一个参数检验的时候不能正常序列化 有什么优雅的办法解决这个问题吗