[MyBatis] parameterType에 중첩 클래스 타입을 넣을 경우
2025. 2. 8. 03:00ㆍTrouble Shootings/Web
Mapper XML에서 Insert SQL 구문을 작성했는데 다음과 같은 에러 메시지가 SpringBoot 로그에서 떴습니다.
Caused by: org.apache.ibatis.builder.BuilderException:
Error resolving class. Cause: org.apache.ibatis.type.TypeException:
Could not resolve type alias 'domain.controller.auth.AuthRequest.RegistrationUserData'.
Cause: java.lang.ClassNotFoundException:
Cannot find class: domain.controller.auth.AuthRequest.RegistrationUserData
이는 MyBatis가 중첩 클래스(Inner Class)를 찾지 못해서 발생하는 문제라고 합니다. 우리가 흔히 풀네임 클래스명을 작성할 땐 패키지명에 따라 `.`으로 잇는 게 일반적인데, 중첩 클래스의 경우에는 `$`으로 이어줘야 한다고 합니다.
<insert id="insertUser" parameterType="domain.controller.auth.AuthRequest$RegistrationUserData"
useGeneratedKeys="true" keyProperty="userId" keyColumn="user_id">
// SQL
</insert>
728x90
반응형
'Trouble Shootings > Web' 카테고리의 다른 글
[MySQL] SpringBoot에서 Point, Polygon 데이터를 자바 객체에 담기 (with MyBatis) (0) | 2025.02.16 |
---|---|
[SpringBoot] @RestControllerAdvice와 Swagger 충돌 (0) | 2025.02.10 |
[MySQL] Error: Data too long for column "컬럼명" (0) | 2025.02.08 |