목차

Kotlin with SpringFramework / JPA

all-open / kotling-spring compiler plugin

no-arg / kotlin-jpa plugin

JPA 지연 로딩에 대해서 강제로 all open 지정 필요

// gradle
plugins {
    kotlin("plugin.spring") version ".."
    kotlin("plugin.jpa") version "..."
}
allOpen {
  annotation("javax.persistence.Entity")
  annotation("javax.persistence.MappedSuperclass")
}

QueryDSL

@Transient 는 getter 사용

// @Transient 불필요.
val fixed: Boolean
    get() = startDate.until(endDate).years < 1

Field 초기화는 lateinit

@Autowired
private lateinit var objectMapper: ObjectMapper

@Entity, @Embeddable, @MappedSuperclass 등.

Jackson

@ConfigurationProperties / @ConstructorBinding

@ConfigurationProperties("...")
@ConstructorBinding
data class MyProperties(val url: String)

참조