
스프링 부트 3으로 코드를 변경해보면서 배운 내용을 공유하는 문서입니다.
이번 글을 통해 배워 갈 내용
- 스프링 부트 2에서 스프링 부트 3 Migration
2 버전 대신에 3으로 넘어가면 좋은 점 및 특징
1.
JVM 대신 GraalVM 을 쓰기 때문에 "navtive" app을 실행 가능하게 하며
startup time 을 줄여주고 memory 관리를 더 효율적이게 하게 됩니다.
2.
Java 17 LTS 이상되는 버전을 써야 하기 때문에
Text block, Records, Sealed class, Switch expression 등 좋은 기능들을 체험하게 됩니다.
3.
Java 기본 버전과 마찬가지로 Jakarta EE 기본 지원 버전을 높여서
javax 대신 jakarta를 패키지 명에 변경하게 됩니다.
먼저 build.gradle.kts 파일에
아래와 같은 plugin을 바꿔주고
// old
plugins {
id("org.springframework.boot") version "2.7.4"
id("io.spring.dependency-management") version "1.0.14.RELEASE"
kotlin("jvm") version "1.6.21"
kotlin("plugin.spring") version "1.6.21"
}
// new
plugins {
id("org.springframework.boot") version "3.0.0"
id("io.spring.dependency-management") version "1.1.0"
kotlin("jvm") version "1.7.21"
kotlin("plugin.spring") version "1.7.21"
}
자바 버전을 올려줍니다.
// old
java.sourceCompatibility = JavaVersion.VERSION_11
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "11"
}
}
// new
java.sourceCompatibility = JavaVersion.VERSION_17
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "17"
}
}
그다음
project structure의 프로젝트 버전을 17 이상으로 올려주고

Reload Project from Disk
Load Gradle Changes를 해준 다음
필요시 javax로 된 모든 부분과 Security Config의 Deprecated 된 부분 등을 수정해주고
배포를 위해서
gradle-wrapper.properties의 distribution Url 도 수정해줍니다.
# before
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
# after
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
실행이 잘되는 것을 확인하였습니다.

필요시 스프링 부트 3.0과 호환이 안 되는 Jasypt Library 등을 삭제해주셔야 되는 경우도 있습니다.
참조 및 인용
https://docs.spring.io/spring-native/docs/current/reference/htmlsingle/
Spring Native documentation
The GraalVM native image tracing agent allows to intercept reflection, resources or proxy usage on the JVM in order to generate the related native configuration. Spring Native should generate most of this native configuration automatically, but the tracing
docs.spring.io
블로그 추천 포스트
https://codemasterkimc.tistory.com/50
300년차 개발자의 좋은 코드 5계명 (Clean Code)
이번 글을 통해 배워갈 내용 좋은 코드(Clean Code)를 작성하기 위해 개발자로서 생각해볼 5가지 요소를 알아보겠습니다. 개요 좋은 코드란 무엇일까요? 저는 자원이 한정적인 컴퓨터 세상에서 좋
codemasterkimc.tistory.com
오늘도 즐거운 코딩 하시길 바랍니다 ~ :)
'Spring' 카테고리의 다른 글
| 스프링 부트 3.3 업데이트 이후 NullPointerException UnsatisfiedDependencyException 이 발생한다면 (1) | 2023.02.26 |
|---|---|
| Spring 3.0에서 profiles 를 이용해 Local, Develop, Production 등에 맞게 이용해보기 (0) | 2023.02.04 |
| Spring Boot PostgreSql PostGIS 설치 및 사용 (0) | 2022.12.10 |
| Kotlin Spring @Valid 가 적용이 안될때 시도해볼 방법 (3) | 2022.11.17 |
| Spring Boot jasypt를 통한 Credentials 암호화 (0) | 2022.11.05 |