Skip to content

Instantly share code, notes, and snippets.

@A-pZ
Created June 1, 2021 06:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save A-pZ/54ad4c9824a9522b4b5c81681db4aa23 to your computer and use it in GitHub Desktop.
Save A-pZ/54ad4c9824a9522b4b5c81681db4aa23 to your computer and use it in GitHub Desktop.
Spring Scheduler Setting
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);
}
}
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