220809 cron 표현식, properties 로그에 테이블 표시, 예외처리

Jongleee·2022년 8월 9일
2

TIL

목록 보기
23/576

cron 표현식

초(0-59) 분(0-59) 시간(0-23) 일(1-31) 월(1-12) 요일(1-7)
@Scheduled(cron="*/10 * * * * *")

10초에 한번씩실행

@Scheduled(cron="0 0 1 * * *")

매일 오전 1시

properties 로그에 테이블 표시

spring.jpa.properties.hibernate.show_sql= true

예외처리

컨트롤러 내부 (@ExceptionHandler)

    @ExceptionHandler(IllegalArgumentException.class)///예외 이름
    public ResponseDto<?> handlingException(){
        return ResponseDto.fail("에러코드","에러메시지");
    }

전역 설정 (@ControllerAdvice)

@RestControllerAdvice
public class ExceptionControllerAdvice {

    @ExceptionHandler(IllegalArgumentException.class)///예외 이름
    public String handleException() {
        return "IllegalArgumentException!";
    }
}

0개의 댓글