Created
June 1, 2021 06:12
-
-
Save A-pZ/54ad4c9824a9522b4b5c81681db4aa23 to your computer and use it in GitHub Desktop.
Spring Scheduler Setting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.scheduling.annotation.EnableScheduling; | |
@SpringBootApplication | |
@EnableScheduling | |
public class SchedulerSampleApplication { | |
public static void main(String[] args) { | |
SpringApplication.run(SchedulerSampleApplication.class, args); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.scheduling.annotation.Scheduled; | |
import org.springframework.stereotype.Service; | |
import com.github.apz.repository.TaskRepository; | |
import lombok.AllArgsConstructor; | |
import lombok.extern.slf4j.Slf4j; | |
@Service | |
@AllArgsConstructor | |
@Slf4j | |
public class TaskSchedulerService { | |
TaskRepository repository; | |
@Scheduled(cron = "0/10 * * * * ?", zone="Asia/Tokyo") | |
public void registerNormal() { | |
log.info("****normal"); | |
repository.register("normal"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment