📖 How to make Composite Keys in Spring Entity
🚩Issue : jakarta.validation.UnexpectedTypeException
{"timestamp":"2024-01-09T03:05:08.657+00:00","status":500,"error":"Internal Server Error","path":"/api/v1/posts"}
jakarta.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint 'jakarta.validation.constraints.Size' validating type 'java.lang.Integer'. Check configuration for 'deadlineMins'
Integer validator가 없다고 함
public class SpringValidatorAdapter implements SmartValidator, jakarta.validation.Validator {
이 파일 살펴봄
@Override
public void validate(Object target, Errors errors) {
if (this.targetValidator != null) {
processConstraintViolations(this.targetValidator.validate(target), errors);
}
}
Integer가 저기서 취급하는게 아닌가봄
⛳Solution : Integer에 @Size 대신 @Min 혹은 @Max 사용
Size로 쓰면 안되고 Min이나 Max annotation을 써야한다고 함
@NotNull
@Size(max=60)
Integer deadlineMins,
@NotNull
@Size(max=3)
Integer deadlineHour,
→
@NotNull
@Max(59)
Integer deadlineMins,
@NotNull
@Max(3)
Integer deadlineHour,
'개발일지' 카테고리의 다른 글
2024-01-11, Today I Learned (1) | 2024.01.11 |
---|---|
2023-01-10, Today I Learned (0) | 2024.01.10 |
2024-01-08, Today I Learned (1) | 2024.01.08 |
2024-01-03, Today I Learned (0) | 2024.01.03 |
2024-01-02, Today I Learned (0) | 2024.01.02 |