Getting Started | Building web applications with Spring Boot and Kotlin
새 프로젝트 만들기
Kotlin-JPA Plugin = All-open compiler plugin
final
.open
을 요구하는 Spring AOP 같은 프레임워크를 사용하기 불편함.
open
키워드 없이도 가능하도록@Component
, @Service
, @Repository
, @Configuration
, @Controller
, @RestController
, @SpringBootApplication
)이 붙은 클래스들을 자동으로 open
으로 만들어줌import org.springframework.stereotype.Service
@Service
open class MyService {
fun performService() {
//
}
}
kotlin-spring
플러그인을 사용하는 경우import org.springframework.stereotype.Service
@Service
class MyService {
fun performService() {
println("Service is being performed")
}
}
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "3.2.2"
id("io.spring.dependency-management") version "1.1.4"
kotlin("jvm") version "1.9.22"
kotlin("plugin.spring") version "1.9.22"
kotlin("plugin.jpa") version "1.9.22"
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
}
}