먼저 시작 클래스에서 주석을 추가하십시오 : @enablescheduling이 타이밍 작업을 시작하십시오.
@springbootApplication@enableschedulingpublic 클래스 응용 프로그램 {public static void main (String [] args) {springApplication.run (application.class, args); }}그런 다음 새로운 시간이 지정된 작업 클래스를 만듭니다
@ComponentPublic Class QuartzService {/** * 시간 표현식을 통해 타이밍 작업 실행 */@scheduled (cron = "0 0/1 * *? } / ***시작 시간 후 x 밀리 초마다 한 번 실행* / @scheduled (fixedRate = 5000) public void timertozzp () {system.out.println ( "fixtRate :" + new random (). NextLong () + new simpledateformat ( "hh : mm : ss"). } / *** 종말점 후 x 밀리 초마다 한 번 실행하십시오* / @scheduled (fixedDelay = 10000) public void timertoreportCount () {system.out.println ( "fixedDelay :" + new random (). NextLong () + New SimpledateFormat ( "HH : MM : SS")))). } / ** * 첫 번째 지연은 x 밀리 초이며, 고정 레이트 규칙 * / @scheduled (initialdelay = 100000, fixedRate = 6000) public void timertoreport () {System.out.out.println ( " + new Random (). NextLong () + new simpledateformat ( "hh : mm : ss"). 형식 (new date ()); }}프로젝트를 시작하고 예정된 작업을 시작하십시오
요약
위는 편집자가 소개 한 SpringBoot 타임 메이드 작업 처리의 구현 코드입니다. 나는 그것이 당신에게 도움이되기를 바랍니다. 궁금한 점이 있으면 메시지를 남겨 주시면 편집자가 제 시간에 답장을 드리겠습니다. Wulin.com 웹 사이트를 지원해 주셔서 대단히 감사합니다!