[Kotlin]Kotlin + SpringBoot + JPA 공식문서 튜토리얼 따라할 때 주의할 점

정지수 JisooJung·2022년 6월 28일
0

https://spring.io/guides/tutorials/spring-boot-kotlin
https://github.com/spring-guides/tut-spring-boot-kotlin
https://github.com/jiso0jung/kotlin-practice
IntelliJ IDEA 2022.1 (Ultimate Edition) 기준

  1. MockMvc를 사용할 때 controller가 받는 모든 bean 대해 @MockkBean으로 선언해두어야 한다.
    • ArticleControllerTest의 경우 UsersRepository를 사용하진 않지만 클래스가 참조할 수 있는 범위 내에서 @MockkBean으로 선언되어 있어야 한다.
    • 선언하지 않으면 테스트 실행 시 bean of type 'xxx' that could not be found. 에러가 발생한다.
  2. kapt를 사용할 때 Preferences | Build, Execution, Deployment | Compiler | Annotation Processors 에서 enable annotation processing가 체크되어 있어야 한다.
    • 체크가 해제되어 있다면 체크 후 IDE를 재실행 하자.
  3. annotationProcessor("org.springframework.boot:spring-boot-configuration-processor") 는 꼭 추가하지 않아도 된다.
    • spring boot configuration annotation processor not configured intellij 경고창이 신경쓰이겠지만 kapt로 이미 import 해주었으므로 정상동작한다. 무시하자..
    • @ConfigurationProperties("demo") 사용 시 initializer에 null 허용 처리를 하지 않고 application.yaml에 관련 키값을 선언하지 않는다면 NPE가 발생한다.
profile
Study&Work&Log

0개의 댓글