티스토리 뷰

개발

spring boot 3.0 version upgrade

달리는개발자 2023. 7. 21. 10:07

신규 프로젝트에 버전을 2.7에서 3.x로 변경했습니다.

한번 오픈하고 서비스되기 시작하면 큰 변화는 꿈도 꿀 수 없죠

리더가 대단한 모험가가 아니라면 대부분 안정되게 가려고 합니다.

위에서 상위 버전을 쓴다고 알아주지도 않는데 괜한 모험을 할 이유가 없겠죠

 

우선 spring boot 3.0으로 가기 위해서 아래 문서를 참고하면 좋습니다.

https://spring.io/blog/2022/05/24/preparing-for-spring-boot-3-0

 

Preparing for Spring Boot 3.0

Spring Boot 2.0 was the first release in the 2.x line and was published on Feburary 28th 2018. We’ve just released Spring Boot 2.7 which means that, so far, we’ve been maintaining the 2.x line for just over 4 years. In total we’ve published 95 distin

spring.io

 

위에 문서 중에 큰 변경이라고 생각되는 부분만 요약해봅니다.

 

JAVA 17 업그레이드

먼저 java 17로 업그레이드 해야겠죠

spring boot 3.0부터는 기본적으로 java 17이 요구됩니다.

저희 같은 경우 컴파일은 우선 11로 두고 구동될 jvm 먼저 java 17로 적용했습니다.

jvm은 버전을 올리는 것은 좋은 방법입니다. jvm 성능이 올라가니 자연스럽게 애플리케이션단에 성능 향상도 기대해볼 수 있겠죠

근데 트래픽이 적은 애플리케이션은 사실 의미 없습니다.

 

jakarta api 패키지 변경

Jakarta EE 9 APIs (jakarta.*) instead of EE 8 (javax.*)

import javax.* 로 되어있던 부분을 import jakarta.*로 변경되어야 됩니다.

아래와 같은 식으로 말이죠. jpa 관련된 api 말고도 여러가지가 있습니다.

javax.persistence =>  jakarta.persistence

 

 

https://www.inflearn.com/questions/722428/javax-inject-provider-%EC%A3%BC%EC%9E%85-%EC%A7%88%EB%AC%B8

 

javax.inject Provider 주입 질문 - 인프런 | 질문 & 답변

[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오) 예2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 예3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)

www.inflearn.com

 

https://www.inflearn.com/chats/788304/spring-boot-3-0-2%EB%A5%BC-%EC%82%AC%EC%9A%A9-%EC%A4%91%EC%9D%B4%EC%8B%A0-%EB%B6%84%EB%93%A4%EC%9D%B4-%EC%84%A4%EC%A0%95%ED%95%98%EB%A9%B4-%EC%A2%8B%EC%9D%80-%EA%B2%83

 

Spring Boot 3.0.2를 사용 중이신 분들이 설정하면 좋은 것 - 인프런 | 고민있어요

application.properties에 다음 설정을 추가해주세요.logging.level.org.springframework.core.LocalVariableTableParameterNameDiscoverer = error이 것은 Controller가 처음 실행될 때 ...

www.inflearn.com

 

 

https://spring.io/blog/2023/03/30/context-propagation-with-project-reactor-3-unified-bridging-between-reactive

 

 

java.lang.NoClassDefFoundError: org/springframework/restdocs/operation/QueryStringParser

spring boot 3.x로 올리면서 spring rest docs 버전이 2.0.6.RELEASE로 사용되었음

 

.exchangeToMono(clientResponse -> {
                    HttpStatus httpStatus = clientResponse.statusCode();

=>

.exchangeToMono(clientResponse -> {
                    HttpStatusCode httpStatus = clientResponse.statusCode();

 

Spring security 관련

subscriberContext 메서드가 없어져서 contextWrite로 변경했습니다.

https://github.com/reactor/reactor-core/issues/2572

 

Mono.subscriberContext methods are deprecated, but javadoc do not describe use what to replace them · Issue #2572 · reactor/re

Mono.subscriberContext methods are deprecated, but javadoc do not describe use what to replace them currently I use ContextHolder (with Mono.subscriberContext in it) to hold request object. what's ...

github.com

 

아래 설정 부분은 기존과 다르게 명확해졌습니다.

and()로 체이닝하던 부분은 명확하게 나눠졌습니다.

.csrf().disable()
                .formLogin().disable()
                .httpBasic()

=>

.csrf(ServerHttpSecurity.CsrfSpec::disable)
                .formLogin(ServerHttpSecurity.FormLoginSpec::disable)
                .httpBasic(ServerHttpSecurity.HttpBasicSpec::disable)

 

 

webflux micrometer tracing 관련

이제 spring cloud sleuth에서 지원하는 마지막 spring boot 버전은 2.x입니다

프로젝트는 micrometer tracing으로 이동했고 spring boot 3.0부터는 micrometer tracing을 적용해야됩니다.

https://micrometer.io/docs/tracing

아래 migration guide를 참고하면 됩니다.

https://github.com/micrometer-metrics/tracing/wiki/Spring-Cloud-Sleuth-3.1-Migration-Guide

 

Spring Cloud Sleuth 3.1 Migration Guide

Provides tracing abstractions over tracers and tracing system reporters. - micrometer-metrics/tracing

github.com

 

처음에 적용하고 나서 traceId, spanId가 안 보이는 현상이 있었습니다.

reactor 3.5.3 부터 아래 hook 호출하면 됩니다. 성능에 문제가 있는지는 개별적으로 확인이 필요해보입니다.

그 이하 버전에서는 수동으로 설정해야된다고 하네요

Hooks.enableAutomaticContextPropagation();

 

https://github.com/spring-projects/spring-boot/issues/34201

 

Provide a setting for automatic context propagation with reactor-core · Issue #34201 · spring-projects/spring-boot

reactor-core 3.5.3 introduced a way to automatically propagate ThreadLocal values registered with the context-propagation library. Combined with the use of micrometer-tracing it can allow users to ...

github.com

 

https://github.com/spring-projects/spring-boot/issues/34695

 

Memory Leak in WebFlux 3.0 + micrometer-tracing-bridge-brave + enableAutomaticContextPropagation · Issue #34695 · spring-proje

Hi, In production, I've upgraded from spring boot webflux + zipkin 2.7.x App to spring boot webflux + zipkin 3.0.4 and I have noticed a memory leak in the heap. I've distilled the problem down and ...

github.com

 

신규 프로젝트여서 오랜만에 spring boot 버전 업그레이드를 했는데 이 부분말고 여러 이슈들이 있었고

구글링하면서 적용해보면 크게 문제 되는 부분은 없었습니다.

이제 성능 테스트 등을 하면서 이슈가 될 만한 부분을 또 찾아봐야겠네요

반응형
댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함