본문 바로가기
728x90
반응형

전체 글173

[SpringBoot] JPA Comment (주석 추가) 설정 방법 JPA Comment (주석 추가) 설정 방법 application.yml spring: 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 potentially disable the hints applie.. 2024. 2. 2.
[mysql] JAVA에서 INET_ATON, INET_NTOA 함수 사용 INET 함수는 ip를 정수로, 정수를 ip로 변환하는 함수입니다. 자바에서 hibernate를 사용하게 되면 SQL을 직접 사용하지 않기 때문에, 자바에서 INET 함수를 사용하는 방법을 알아보겠습니다. INET_ATON IP 주소의 숫자 값을 반환합니다. IPv4 네트워크 주소가 점으로 구분된 쿼드 문자열로 표현될 때, 네트워크 바이트 순서(big endian)로 주소의 숫자 값을 나타내는 정수를 반환합니다. INET_ATON()은 인수를 이해하지 못하거나 expr이 NULL인 경우 NULL을 반환합니다. mysql> SELECT INET_ATON('10.0.5.9'); -> 167773449 이 예제에서 반환 값은 (10×256)^3 + (0×256)^2 + 5×256 + 9로 계산됩니다. 자바 코.. 2023. 9. 6.
[QueryDSL] FullText 검색을 위한 Match ... against 절 사용법 MySQL에서 FullText 인덱스 검색을 하기 위해서는 MATCH(), AGAINST() 절을 사용해야합니다. (풀텍스트 인덱스에 대한 설명은 다른 블로그 포스팅을 참고해주세요.) 기존에 dialect는 MySQL5Dialect를 사용하고 있었습니다. properties.put("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect"); MySQL5Dialect를 커스텀하겠습니다. package com.moonsiri.config.hibernate.dialect; import org.hibernate.dialect.MySQL5Dialect; import org.hibernate.dialect.function.SQLFunctionTemplate; impo.. 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.
[SpringBoot] JPA Master/Slave 구조 분기 처리 서비스를 운영하다 보면 데이터베이스가 여러 개의 노드로 분산되어 Master/Slave 구조로 이루어져 있는 경우가 많습니다. 보통 두가지 방법으로 분기처리가 가능한데요. 본 포스팅에서는 @Transactional 어노테이션을 사용하는 방식을 소개해드리겠습니다. 먼저 Transactional readOnly에 따라 분기하는 CustomRoutingDataSource를 생성합니다. import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; import org.springframework.transaction.support.TransactionSynchronizationManager; public class RoutingDataS.. 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.
[Spring] RestTemplate Deprecated의 진실 Spring framework에서 제공하는 Http Client API로 RestTemplate이 있습니다. 그런데 인터넷에서 RestTemplate이 Deprecated 된다는 얘기를 종종 볼 수 있습니다. 하지만 최근 문서에서는 WebClient 사용을 권고하는 말 뿐, RestTemplate을 Deprecated 한다는 말은 없습니다. 그럼 왜 RestTemplate이 Deprecated된다는 소문이 퍼진 걸까요? 확인해 보니 spring 5.2.1.RELEASE 버전 문서에 RestTemplate가 Deprecated 될 예정이라고 써져 있었습니다. 이 문서가 소문의 근원지가 아닐까 싶습니다. 그런데 spring github issue에도 다음과 같은 글이 올라와있습니다. "향후 사용 중단 가능성.. 2023. 7. 13.
[Intellij] VisualVM 연동 및 사용법 1. VisualVM 설치 https://visualvm.github.io/download.html VisualVM: Download Download VisualVM is distributed as a standalone tool at GitHub, and as an optional component of the GraalVM. Both are the same bits with the same features. Standalone tool runs on any compatible JDK, component is configured to run using the host GraalVM. visualvm.github.io 2. Intellij + VisualVM 연동 Settings > Plugin에서 Vi.. 2023. 7. 13.
[AWS SDK for JAVA] EC2 보안그룹(Security Group) 조회 AWS SDK for JAVA 2.X 으로 EC2 인스턴스에 설정된 보안그룹을 조회해보겠습니다. 1. pom.xml에 라이브러리 추가 software.amazon.awssdk ec2 2.20.87 ※ groupId가 software이면 version 2, com.amazonaws이면 version 1입니다. 2. Ec2Client 생성 2.1. iam role 사용 import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.ec2.Ec2Client; @Configuration public class AwsEC2Configuration { @Resource private Environment env; @Bean p.. 2023. 6. 21.
728x90
반응형