์ƒ์„ธ ์ปจํ…์ธ 

๋ณธ๋ฌธ ์ œ๋ชฉ

[์€ผ] Spring Boot 2.x -> Spring Boot 3.x ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ ์—ฌ์ •

๋ณธ๋ฌธ

์Šคํ”„๋ง ๋ถ€ํŠธ 3.0 ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ ๊ฐ€์ด๋“œ (๋ฒˆ์—ญ)

 

Spring Boot 3.0 Migration Guide

Spring Boot helps you to create Spring-powered, production-grade applications and services with absolute minimum fuss. - spring-projects/spring-boot

github.com

1) Java ๋ฒ„์ „ 17 ์ด์ƒ์œผ๋กœ ์—…๊ทธ๋ ˆ์ด๋“œ ํ•˜๊ธฐ 

- Spring Boot 3.x ์€ ๋”์ด์ƒ Java8์„ ์ง€์›ํ•˜์ง€ ์•Š๋Š”๋‹ค 

 

2) ์Šคํ”„๋ง ๋ถ€ํŠธ๋ฅผ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ์ตœ์‹  ๋ฒ„์ „์œผ๋กœ ์—…๊ทธ๋ ˆ์ด๋“œ ํ•˜๊ธฐ

- 2.7.x ๋กœ ์—…๊ทธ๋ ˆ์ด๋“œ 

 

3) Spring Boot์—์„œ ๊ด€๋ฆฌ๋˜์ง€ ์•Š๋Š” ์ข…์†์„ฑ ํ™•์ธํ•˜๊ธฐ 

- ์Šคํ”„๋ง ๋ถ€ํŠธ 2.7.x : https://docs.spring.io/spring-boot/docs/2.7.x/reference/html/dependency-versions.html#appendix.dependency-versions

 

Dependency Versions

 

docs.spring.io

 

- ์Šคํ”„๋ง ๋ถ€ํŠธ 3.0.x : https://docs.spring.io/spring-boot/docs/3.0.x/reference/html/dependency-versions.html#appendix.dependency-versions

 

Dependency Versions

 

docs.spring.io

 

์‹œํ๋ฆฌํ‹ฐ, ํด๋ผ์šฐ๋“œ, ๋ฐฐ์น˜

(1) Spring Security

- Spring Security 6.0 ์‚ฌ์šฉ (Spring Boot 3.0)

   Spring Security 5.8 (Spring Boot 2.7) ๋กœ ์—…๊ทธ๋ ˆ์ด๋“œ ํ•œ ํ›„์— Spring Security 6.0์œผ๋กœ ๋ณ€๊ฒฝํ•˜๊ธฐ 

https://docs.spring.io/spring-security/reference/6.0/migration/index.html

 

Migrating to 6.0 :: Spring Security

Now that you are updated, you need to change your javax imports to jakarta imports.

docs.spring.io

 

- ์„œ๋ธ”๋ฆฟ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ Spring Secuirt 6.0์€ ๋ชจ๋“  ๋””์ŠคํŒจ์น˜ ์œ ํ˜•์— ๊ถŒํ•œ ๋ถ€์—ฌ๋ฅผ ์ ์šฉํ•œ๋‹ค.

์ด์— ๋งž์ถฐ Spring Boot๋Š” ๋ชจ๋“  ๋””์ŠคํŒจ์น˜ ์œ ํ˜•์— ๋Œ€ํ•ด Spring Security ํ•„ํ„ฐ๊ฐ€ ํ˜ธ์ถœ๋˜๋„๋ก ๊ตฌ์„ฑํ•œ๋‹ค.

๋””์ŠคํŒจ์น˜ ์œ ํ˜•์€ spring.security.filter.dispatcher-types ์†์„ฑ์„ ์‚ฌ์šฉํ•˜์—ฌ ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋‹ค. 

 

(2) Spring Batch 

- Spring Batch 5.0 ์‚ฌ์šฉ 

https://github.com/spring-projects/spring-batch/wiki/Spring-Batch-5.0-Migration-Guide

 

Spring Batch 5.0 Migration Guide

Spring Batch is a framework for writing batch applications using Java and Spring - spring-projects/spring-batch

github.com

๋” ์ด์ƒ @EnableBatchProcessing ํ•„์š”์—†์Œ

Job๊ณผ Step์„ ๋งŒ๋“ค ๋•Œ, JobRepository, PlatformTransactionManager ํŒŒ๋ผ๋ฏธํ„ฐ๊ฐ€ ํ•„์š”ํ•จ 

JobBuilderFactory์™€ StepBuilderFactory๊ฐ€ ์ง€์›์ด ์ค‘๋‹จ๋˜์—ˆ๊ณ , JobBuilder์™€ StepBuilder๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•จ 

 

(3) Spring Cloud

- Spring Cloud Bom ์—…๋ฐ์ดํŠธ

- application.yml ํ˜น์€ application.properties ์ˆ˜์ •

- Spring Cloud Sleuth๋ฅผ Micrometer Tracing ์œผ๋กœ ์ด๊ด€ 

 

(4) Flyway : 9.22.3 

(5) Mockito : 5 ์‚ฌ์šฉ

(6) springdoc-openapi : ๋ถ€ํŠธ3์„ ์ง€์›ํ•˜๊ธฐ ์œ„ํ•œ ์•„ํ‹ฐํŒฉํŠธID ๋กœ ๋ณ€๊ฒฝ 


์ง์ ‘ ํ•ด๋ณด์ž 

์š”์•ฝ

- ์Šคํ”„๋ง ๋ถ€ํŠธ 3.0 ๋ฒ„์ „ : Spring Boot 3.5.4

- Java 17์ด์ƒ : Java21

- ์Šคํ”„๋ง ์‹œํ๋ฆฌํ‹ฐ 6.0 : Spring Security 6.0

- ์Šคํ”„๋ง ๋ถ€ํŠธ 2.x @Deprecated ์ œ๊ฑฐ 

 

 

1. ์ž๋ฐ” ๋ฒ„์ „์„ 21๋กœ ์˜ฌ๋ ธ๋‹ค

- ์‹คํ–‰์— ์‚ฌ์šฉ๋˜๋Š” ํ˜„์žฌ Gradle(8.13)์ด Java 21๊ณผ ํ˜ธํ™˜๋˜์ง€ ์•Š์•„ JAR ์ƒ์„ฑ ๋‹จ๊ณ„์—์„œ ์‹คํŒจํ–ˆ๋‹ค 

 

1.1. Gradle์„ 8.13 ๋ฒ„์ „์œผ๋กœ ์—…๊ทธ๋ ˆ์ด๋“œ๋ฅผ ํ–ˆ๋‹ค 

- ๋ช…๋ น์–ด ๋ฐฉ์‹ (์ž„์‹œ๋กœ 19๋กœ ๋‚ด๋ ค์„œ ์—…๊ทธ๋ ˆ์ด๋“œ ์‹คํ–‰ ํ›„ ๋‹ค์‹œ 21๋กœ ๋ณ€๊ฒฝ)

chmod +x ./gradlew

./gradlew wrapper --gradle-version 8.13

 

- ์ˆ˜๋™ ์—…๊ทธ๋ ˆ์ด๋“œ ๋ฐฉ์‹ 

gradle/wrapper/gradle-wrapper.properties ํŒŒ์ผ ์—ด์–ด์„œ 

distributionUrl=https:\://services.gradle.org/distributions/gradle-8.13-bin.zip ๋กœ ์ˆ˜์ • 

./gradlew clean build --refresh-dependencies


์ €์žฅ ํ›„, ์•„๋ž˜ ์‹คํ–‰

chmod +x ./gradlew

./gradlew --version 

 

2. ํ…Œ์ŠคํŠธ ์ƒ๋žตํ•˜๊ณ  ์‹คํ–‰ ./gradlew bootRun -x test

- Gradle bootRun์— Modify Run Configuration ์„ ํƒ (-x test ์ถ”๊ฐ€)

 

- Jakarata ๋กœ ๋ณ€๊ฒฝ : find and replace ํ•จ ใ…‹

(Ultimate๋ฒ„์ „๋งŒ ๋œ๋‹ค https://blog.jetbrains.com/idea/2021/06/intellij-idea-eap-6/# )

 

- ํŠน์ • ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋งŒ ์ถ”์  ํ•˜๋Š” ๋ฐฉ๋ฒ•

./gradlew dependencyInsight --dependency ์ถ”์ ํ•˜๊ณ ์‹ถ์€๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ

1) ์–ด๋–ค ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ์ถ”์ ํ•˜๊ณ ์‹ถ์€๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๋Œ๊ณ  ์˜ค๋Š”์ง€

2) ์–ด๋–ค ๋ฒ„์ „ ๊ฒฝ๋กœ๋กœ ์ตœ์ข… resolve๋˜๋Š”์ง€

3) ๋ฒ„์ „ ์ถฉ๋Œ์‹œ ์–ด๋–ค ๋ฒ„์ „์ด ์šฐ์„ ๋˜๋Š”์ง€

3๊ฐ€์ง€๋ฅผ ๋ณผ ์ˆ˜ ์žˆ๋‹ค 

 

(1) gradle/wrapper/gradle-wrapper.properties 

build.gradle ์˜ org.springframework.boot ๋ฒ„์ „์„ 3.5.4 ๋กœ ์˜ฌ๋ ธ๋‹ค 

 


์—ฌ๋Ÿฌ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ ๋„์™€์ฃผ๋Š” ๋„๊ตฌ 

1) Intellij Migration Tool

- Jakarata ๋กœ ๋ณ€๊ฒฝ

https://blog.jetbrains.com/idea/2021/06/intellij-idea-eap-6/#

 

IntelliJ IDEA EAP 6: Automatic Migration From Java EE to Jakarta EE, Shared Indexes for Spring Boot Projects, and More | The Int

IntelliJ IDEA 2021.2 EAP 6 is now available! You can get the new build from our website, through the free Toolbox App, or as a snap (for Ubuntu). In this final EAP before Beta, we have focused on s

blog.jetbrains.com

 

2) JDK17, Maven ํ”„๋กœ์ ํŠธ์—์„œ ์‚ฌ์šฉํ•ด๋ณผ ์ˆ˜ ์žˆ์Œ

https://github.com/spring-projects-experimental/spring-boot-migrator

 

GitHub - spring-projects-experimental/spring-boot-migrator: Spring Boot Migrator (SBM) is a tool for automated code migrations t

Spring Boot Migrator (SBM) is a tool for automated code migrations to upgrade or migrate to Spring Boot - spring-projects-experimental/spring-boot-migrator

github.com

 

3) https://docs.openrewrite.org/

 

OpenRewrite by Moderne | Large Scale Automated Refactoring | OpenRewrite Docs

Large-scale automated source code refactoring

docs.openrewrite.org

 


์ฐธ๊ณ 2. ์Šคํ”„๋ง ๋ถ€ํŠธ3 ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜

https://techblog.lycorp.co.jp/ko/how-to-migrate-to-spring-boot-3

 

์‹ค์ „! Spring Boot 3 ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜

๋“ค์–ด๊ฐ€๋ฉฐ์•ˆ๋…•ํ•˜์„ธ์š”. LINE Plus์—์„œ ํƒœ๊ตญ LINE BK ์ฑ„๋„ ์„œ๋ฒ„ ๊ฐœ๋ฐœ ๋ฐ ์šด์˜ ์—…๋ฌด๋ฅผ ๋งก๊ณ  ์žˆ๋Š” ์ด์„์žฌ์ž…๋‹ˆ๋‹ค. LINE BK์—์„œ๋Š” ์ง€๋‚œ 9์›”์— LINE BK ๋ณดํ—˜ ์ค‘๊ฐœ ์„œ๋น„...

techblog.lycorp.co.jp

 

728x90

๊ด€๋ จ๊ธ€ ๋”๋ณด๊ธฐ