목록Spring/Annotation (2)
hilims 님의 블로그
Spring Boot에서 무거운 작업을 메인 스레드에서 분리해 백그라운드로 실행하고 싶을 때 @Async 애너테이션을 사용하면 매우 간단하게 비동기 처리를 구현할 수 있습니다.1. @EnableAsync로 비동기 기능 활성화Spring Boot에서 @Async를 사용하려면 먼저 @EnableAsync 애너테이션을 선언해야 합니다.@SpringBootApplication@EnableAsyncpublic class AsyncApplication { public static void main(String[] args) { SpringApplication.run(AsyncApplication.class, args); }}2. @Async 기본 사용법@Async는 메서드에 붙여서 별도의 스..
1. 기본 설정 - @EnableScheduling스케줄 기능을 활성화하려면 애플리케이션 클래스에 @EnableScheduling을 선언해야 합니다.@SpringBootApplication@EnableSchedulingpublic class SchedulerApplication { public static void main(String[] args) { SpringApplication.run(SchedulerApplication.class, args); }}2. 기본 사용법 - @Scheduled이제 특정 메서드에 @Scheduled 애너테이션을 붙이면 됩니다.@Componentpublic class MyScheduler { @Scheduled(fixedDelay = 5000..