[서버][스프링][Kotlin] Repeatable annotations with non-SOURCE retention are not yet supported

프로그래밍/서버2021. 3. 26. 19:34

문제 현상

자바로 작성된 코트를 Kotlin으로 변경하니 mapstruct의 인터페이스에서 위와 같은 에러가 발생했습니다.

 

Repeatable annotations with non-SOURCE retention are not yet supported

 

원인

믿기지 않는 사실이지만 아직 코틀린에서 동일한 이름의 반복되는 어노테이션을 처리하지 못하는 것 같습니다.

 

해결 방법

    @Mappings(
        Mapping(source = "roomNo", target = "roomNo"),
        Mapping(source = "roomOrder", target = "roomOrder"),
        Mapping(source = "userId", target = "userId"),
        Mapping(source = "roomId", target = "roomId"),
        Mapping(source = "roomNickName", target = "roomNickName")
    )

다른 어노테이션에서도 항상 사용가능한지 잘 모르겠으나 matstruct에선 Mappings 어노테이션을 지원합니다. 위 코드처럼 모아서 넣으면 됩니다.

 

참고

youtrack.jetbrains.com/issue/KT-12794

 

Allow runtime retention repeatable annotations when compiling under Java 8 : KT-12794

When compiling for Java 8 target, allow repeatable annotations to be used when runtime retention. @Repeatable annotation class Foo(val value: String) @Foo("a") @Foo("b") // [NON_SOURCE_REPEATED_ANNOTATION] Repeatable annotations with non-SOURCE retention a

youtrack.jetbrains.com

 

작성자

Posted by 드리머즈

관련 글

댓글 영역