개발/뭔지모르면여기
Error instantiating class 에러
애쿠
2023. 1. 25. 23:43
nested exception is org.apache.ibatis.reflection.ReflectionException: Error instantiating class 객체명 with invalid types () or values (). Cause: java.lang.NoSuchMethodException: 객체명 <init>()
Mybatis에서 객체를 매핑할때 발생하는 에러로 기본생성자가 없으면 발생하는 에러이다.
setter와 AllargsConstructor의 존재와 상관없이 Mybatis에서 조회 후 객체를 매핑할때 빈 생성자를 반드시 만들어줘야한다.
Lombok을 사용중이면 @NoArgsConstructor 설정해주면 된다.
@Builder
@Getter @Setter
@AllArgsConstructor
@NoArgsConstructor
public class 객체명 {
private String ...
}