Programing 55

Spring Batch 기본 예제

가장 기초적인 예제 코드로 아래 코드를 작성 후 배치 프로젝트를 실행하면 Job이 실행된다. 하나의 Job에는 여러개의 Step이 등록되어 있고. 순서대로 Step1 -> Step2가 실행될것이다. Job, Step 등록하기 package io.spring.springbatch; import lombok.RequiredArgsConstructor; import org.springframework.batch.core.Job; import org.springframework.batch.core.Step; import org.springframework.batch.core.StepContribution; import org.springframework.batch.core.configuration.annotat..

오류) Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

스프링 부트 프로젝트를 실행하는데 다음과 같은 에러가 나타났다. *************************** APPLICATION FAILED TO START *************************** Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Failed to determine a suitable driver class Action: Consider the following: If you want an embedded database (H2, HSQL or Derby), please put i..

JAVA 순열(permutations) 알고리즘

배열의 모든 순열을 재귀적으로 호출하고 출력하는 코드입니다. 여기서 사용되는 개념은 백트래킹과 교환(swap)입니다. 이 알고리즘은 재귀적으로 순열을 생성하며, 각 단계에서 현재 위치(i)를 기준으로 나머지 위치(j)를 교환하여 순열을 생성합니다. 이때 백트래킹을 통해 이전 상태로 돌아갈 수 있도록 배열을 다시 원래대로 되돌립니다. /** 알고리즘 1,2,3 / | \ 123 213 321 i=0, j=0~2 / | \ 123,132 213,231 321,312 i=1, j=1~2 (j가 증가하면서 swap을 한다.) */ public class Permutations { /** * 1,2,3으로 만들 수 있는 모든 경우의 수를 출력한다. */ @Test public void 순열(){ int[] arr..

Programing/Java 2023.08.25

인텔리제이 한글 깨짐 오류 unmappable character (0xEC) for encoding x-windows-94

방금 만든 프로젝트에서 다음과 같이 에러가 나타났다. 해당 오류는 주로 인코딩(encoding) 문제로 인해 발생하는 것으로 보입니다. 주어진 코드 파일 내에 한글 문자 또는 특수 문자 등이 제대로 처리되지 않아서 발생하는 문제입니다. 오류 메시지에 "unmappable character for encoding x-windows-949"라고 나와있는데, 이는 특정 문자가 해당 인코딩 방식(x-windows-949)으로 표현할 수 없다는 의미입니다. 해결방법 File - Settings 창을 띄운 후 File Encodings 검색 오른쪽 사진과 같이 동그라미 친 부분들을 UTF-8로 설정하고 적용. File - Settings 창을 띄운 후 Gradle 검색 오른쪽 사진과 같이 Build and Run ..

Programing/Java 2023.08.25

동시성 문제 해결 - 비관적 락 (Pessimistic Lock)

다음과 같이 영화관 자리를 예매하는 예제가 있다고 할 때 여러명이 동시에 빈 자리를 확인하고 예매를 할 경우 동시에 예매가 되어버리는 문제가 있습니다. import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional @Service class MovieBookingService(private val seatRepository: SeatRepository) { /** * 1. 예매정보가 있는지 조회 * 2. 없다면 예매 */ @Transactional fun bookMovieSeat(hallNumber: String, seatNumber: String): Pair { val ..

vue3 swiper 자동스크롤 사용법

설치 npm i swiper 사용법 (기본예제) Slide 1 //컨텐츠 내용 Slide 2 Slide 3 ... 사용법 (응용) Slide 1 Slide 2 Slide 3 ... 세로 슬라이드 사용을 하려는데 height 값이 너무 크게 나오는 문제가 있었다. 세로 슬라이드 사용시에는 height값을 주어야 한다. 다음과 같이 2군데에 주었다. 공지합니다. {{ item.title }} 공식 문서 https://swiperjs.com/vue Swiper - The Most Modern Mobile Touch Slider Swiper is the most modern free mobile touch slider with hardware accelerated transitions and amazing na..

Programing/CSS 2023.07.24

코틀린 Querydsl Pageble Sort 동적 정렬 쉽게 사용하기 + 유틸화

코틀린에서 Querydsl을 이용하여 pageble객체를 받아 동적으로 정렬하기 위해서 유틸리티 하나를 생성한다. open class QuerydslUtils { fun JPAQuery.withPageable(pageable: Pageable, entityPath: Q): JPAQuery { val query = this.limit(pageable.pageSize.toLong()).offset(pageable.offset) for (o in pageable.sort) { val pathBuilder = PathBuilder(entityPath.type, entityPath.metadata) query.orderBy( OrderSpecifier( if (o.isAscending) Order.ASC else..