Spring Boot 3 과 4
ElastiCORE 3.0 은 Spring Boot 3 과 4 를 모두 지원합니다(2.2 는 Spring Boot 3 만). Spring Boot 4.0.8, Spring AI 2.0.1, Hibernate 7.2, Spring Data JPA 4.0, Jackson 3.1 에서 확인했고, Spring Boot 3 런타임 라이브러리는 3.5.16 에서 테스트합니다.
| Spring Boot 3 | Spring Boot 4 | |
|---|---|---|
| 런타임 라이브러리 | io.elasticore.springboot3:elasticore-springboot3 | io.elasticore.springboot4:elasticore-springboot4 |
| 런타임의 Java 패키지 | io.elasticore.springboot3 | io.elasticore.springboot3 (같음 - 생성 코드의 import 가 바뀌지 않음) |
| 웹 스타터 | spring-boot-starter-web | spring-boot-starter-webmvc |
| springdoc | 2.8.17 | 3.0.3 |
| Gradle | 8.14 이상 | |
| Kotlin | 2.2 이상, Jackson 모듈 tools.jackson.module:jackson-module-kotlin |
Boot 3 에서 4 로 옮길 때는 Boot 플러그인 버전, 런타임 라이브러리 줄, 웹 스타터, springdoc 을 바꿉니다. 생성 코드 의 import 는 바뀌지 않습니다.
ElastiCORE 가 알아서 하는 것
플러그인이 빌드에 적용된 Spring Boot Gradle 플러그인의 버전을 읽습니다(루트에 apply false 로만 선언해도 됨). Boot
4 이면 생성 코드가 필요한 곳에서 바뀝니다:
| 생성물 | Spring Boot 3 | Spring Boot 4 |
|---|---|---|
enum (@json) | Jackson 2 CustomSerializer/CustomDeserializer | @JsonValue + @JsonCreator (Jackson 2·3 공통) |
| outbox recorder (DDD) | Jackson 2 ObjectMapper | Jackson 3 JsonMapper |
| Kotlin | 그대로 | Specification 타입 파라미터에 T : Any, Page.map 에 !! (Spring Data 4 의 JSpecify) |
| HTTP 포트 클라이언트 (런타임) | Jackson 2 코덱 | Jackson 3 코덱 |
HTTP 포트 (선택: httpPort: spring) | ElastiCORE 런타임 | Spring 의 @HttpExchange 인터페이스 + @ImportHttpServices |
| 엔티티, 리포지터리, 서비스, 컨트롤러 | 그대로 | 그대로 |
왜 enum 이 바뀌어야 하나: Spring Boot 4 의 웹 계층은 Jackson 3 으로 JSON 을 씁니다. Jackson 3 은 Jackson 2 의
@JsonSerialize/@JsonDeserialize 를 보지 않으므로, Boot 3 용 enum 은 오류 없이 코드("DRF") 대신
이름("DRAFT")으로 나갑니다.
결정된 버전은 생성 로그 첫머리에 나옵니다:
[ElastiCORE] Spring Boot: 4.0.8 (build) - enums and the outbox are written for Jackson 3
Boot 4 프로젝트인데 Spring Boot: 3 이 보이면 직접 적습니다:
| 어디에 | 쓰는 법 | 언제 |
|---|---|---|
build.gradle | elasticore { springBoot = '4' } | 플러그인이 버전을 읽지 못할 때 (Boot 플러그인 없이 BOM 만, 오래된 Gradle) |
env.yml | elasticore: config: springBoot: 4 | 플러그인 없이 생성할 때 |
| JavaExec | systemProperty 'elasticore.springBoot', '4' | 직접 만든 생성 태스크 |
Pet Store 예제는 springBoot = '4' 를 적습니다: 빌드의 Gradle 이 Boot 4 플러그인보다 오래되어 버전을 읽을 수 없기
때문입니다.
직접 고칠 것
ElastiCORE 가 만들지 않은 코드는 Spring Boot 4 마이그레이션 가이드를 따릅니다. 예제 프로젝트에서 실제로 고친 것:
| 증상 | 수정 |
|---|---|
package org.springframework.boot.test.autoconfigure.web.servlet does not exist | org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc + spring-boot-starter-webmvc-test |
No qualifying bean of type 'com.fasterxml.jackson.databind.ObjectMapper' | tools.jackson.databind.ObjectMapper (Boot 4 는 Jackson 3 매퍼를 등록) |
JsonNode.asText() 경고 | Jackson 3: asString() |
이미 내 것이 된 한 번만 생성되는 파일(XxxService, 컨트롤러)은 다시 생성되지 않습니다.
Spring AI
env.yml 의 supportAI: "true" 는 생성된 서비스 메서드에 Spring AI 의 @Tool/@ToolParam 을 붙입니다(Spring AI
1.x 와 2.0 모두 같은 어노테이션). Boot 4 와 Spring AI 2.0:
implementation platform('org.springframework.ai:spring-ai-bom:2.0.1')
implementation 'org.springframework.ai:spring-ai-model'
@Bean
ToolCallbackProvider erpTools(PartnerService partners, ItemService items) {
return MethodToolCallbackProvider.builder().toolObjects(partners, items).build();
}
@readonly 엔티티나 @restExclude 로 뺀 메서드에는 조회 도구만 생깁니다.