본문 바로가기
728x90
반응형

spring71

[SpringBoot3] RestTemplate (httpclient 4 → 5) 마이그레이션 스프링 프레임워크 6.0에서 Apache HttpClient에 대한 지원이 제거되어, org.apache.httpcomponents.client5:httpclient5로 대체되었습니다. 1. Maven Dependency 변경 org.apache.httpcomponents httpclient org.apache.httpcomponents.client5 httpclient5 2. RestTemplate Migration공식 문서를 보고 변경하는 것이 좋습니다.HttpComponentsClientHttpRequestFactory 클래스로 readTimeout과 connectTimeout을 설정하던 코드가 HttpClientConnectionManager 클래스를 통해 timeout 관련 설정 후 .. 2024. 5. 7.
Spring Security 5에서 Spring Security 6으로 변경 (URL-권한 인가) Overview스프링 부트 3.0부터 스프링 시큐리티 6 버전이 적용되었습니다. 삭제되거나 deprecated된 코드가 많아서 마이그레이션 시 주의할 부분에 대해 알려드리겠습니다.기존 버전 : 5.3.3.RELEASE최신 버전 : 6.2.4 Summary기존 WebSecurityConfigurationAdapter를 상속받아 세팅하던 방식은 삭제되었고 SecurityFilterChain bean을 스프링 컨테이너에 등록해줘야함.authorizeRequests() → authorizeHttpRequests()로 변경antMatchers() → requestMatchers()로 변경로그인 페이지 리다이렉트 반복 접근 이슈 발생 시.dispatcherTypeMatchers(DispatcherType.FORWA.. 2024. 4. 30.
ehcache2(net.sf.ehcache)에서 ehcache3(org.ehcache)로 변경 OverviewSpring Boot 3.0에서는 ehcache2에 대한 지원이 제거되었습니다.Jakarta EE 9 이상을 지원하기 위해 ehcache 및 ehcache-transactions 모듈에 대한 종속성 관리가 jakarta를 사용하여 선언되어 ehcache3로 버전을 업그레이드해야합니다. Migration1. Maven dependency 추가V2) net.sf.ehcache ehcache 2.10.6 org.springframework.boot spring-boot-starter-cache 2.3.2.RELEASEV3) org.ehcache ehcache 3.10.8 jakarta org.springframework.boot s.. 2024. 4. 30.
[JPA] Entity에 Enum 사용하기 JPA Entity에서 Enum 사용하는 이유코드 가독성Enum을 사용하면 코드의 가독성이 높아집니다. Enum은 코드에서 명시적으로 정의된 상수 집합이므로 해당 값을 사용하는 곳에서는 해당 의미를 명확하게 이해할 수 있습니다.안전성Enum을 사용하면 오타나 잘못된 값으로 인한 오류를 방지할 수 있습니다. 컴파일러는 Enum 값의 유효성을 검사하므로 잘못된 값이 사용되는 경우 컴파일 오류가 발생합니다.유지보수성코드에서 Enum 값을 수정할 때 해당 Enum을 사용하는 모든 곳을 찾아 수정할 필요가 없습니다. Enum 값만 수정하면 되므로 유지보수가 쉽습니다.타입 안정성Enum을 사용하면 타입 안정성이 보장됩니다. Enum 값은 해당 Enum 타입으로만 제한되므로 다른 타입의 값을 실수로 사용하는 문제를 .. 2024. 4. 25.
[SpringBoot] JPA Comment (주석 추가) 설정 방법 JPA Comment (주석 추가) 설정 방법 application.ymlspring: jpa: properties: hibernate: show_sql: false format_sql: true use_sql_comments: true # sql comments 사용 1. JPA Repository에 적용 방법To apply JPA QueryHints to the queries declared in your repository interface you can use the QueryHints annotation. It takes an array of JPA QueryHint annotations plus a boolean flag to potentiall.. 2024. 2. 2.
[QueryDSL] FullText 검색을 위한 Match ... against 절 사용법 MySQL에서 FullText 인덱스 검색을 하기 위해서는 MATCH(), AGAINST() 절을 사용해야합니다.(풀텍스트 인덱스에 대한 설명은 다른 블로그 포스팅을 참고해주세요.) 기존에 dialect는 MySQL5Dialect를 사용하고 있었습니다.properties.put("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect"); MySQL5Dialect를 커스텀하겠습니다.// hibernate 5package com.moonsiri.config.hibernate.dialect;import org.hibernate.dialect.MySQL5Dialect;import org.hibernate.dialect.function.SQLFunctionTempl.. 2023. 8. 24.
[SpringBoot] QueryDSL org.apache.jasper.JasperException: Unable to compile class for JSP: 배경 JSP를 사용하는 환경에서 QueryDSL 라이브러리를 추가 후 빌드 시 'QueryDSL org.apache.jasper.JasperException: Unable to compile class for JSP:' 오류가 발생 원인 querydsl-apt 내 org.eclipse.jdt.core.compiler:ecj 종속성 강제 해결 querydsl-apt에 org.eclipse.jdt.core.compiler:ecj 종속성 제외 com.querydsl querydsl-apt provided org.eclipse.jdt.core.compiler ecj 2023. 8. 24.
[SpringBoot2] JPA Master/Slave 구조 분기 처리 서비스를 운영하다 보면 데이터베이스가 여러 개의 노드로 분산되어 Master/Slave 구조로 이루어져 있는 경우가 많습니다.보통 두가지 방법으로 분기처리가 가능한데요. 본 포스팅에서는 @Transactional 어노테이션을 사용하는 방식을 소개해드리겠습니다.  먼저 Transactional readOnly에 따라 분기하는 CustomRoutingDataSource를 생성합니다.import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;import org.springframework.transaction.support.TransactionSynchronizationManager;public class RoutingDataSour.. 2023. 8. 23.
[WebFlux] Mono에 담긴 List를 하나로 합치기 Spring WebClient를 통해 동일한 객체타입을 리턴하는 여러 외부 API를 호출하면서 Mono를 List로 담았는데, 각 API 호출 응답으로 받은 객체가 List여서 Flux.merge(monoList).collectList() 타입이 Mono이 돼버렸습니다. Mono가 아닌 Mono로 리턴할 수 있는 방법을 알아보겠습니다. 우선 아래 코드를 비교해 확인해 주세요. // AS-IS public Mono getList(...) { List monoList = new ArrayList(); Mono listMono1 = Mono.just(List.of(...)); monoList.add(listMono1); Mono listMono2 = Mono.just(List.of(...)); monoList.. 2023. 7. 13.
[Spring] WebMVC에서 WebFlux 사용 (with WebClient) Spring에는 두 가지 웹 프레임워크가 있습니다. WebMVC : 전통적인 멀티 스레드 기반의 웹 프레임워크 WebFlux : 리액티브 스택 기반의 웹 프레임워크 Spring WebMVC와 WebFlux는 공존할 수 없다고 생각했는데, Spring framework에서 제공하는 Http Client API로 RestTemplate 대신 WebClient를 사용하라고 권고하고 있어서 의문이 생겼습니다. 두 모듈의 공존이 가능한 것인가? Spring 문서를 확인해보면 "애플리케이션은 하나 또는 다른 모듈을 사용하거나 경우에 따라 두 모듈을 모두 사용할 수 있습니다(예: 반응형 WebClient가 포함된 Spring MVC 컨트롤러)."라고 써져 있습니다. 실제로 spring-boot-starter-web,.. 2023. 7. 13.
728x90
반응형