spring boot 实际应用(七) 定时任务

    xiaoxiao2021-03-25  100

    定时任务采用注解的模式使用

    1、增加开启定时任务配置

    package com.ecej.meterread.task.base.config; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.EnableScheduling; @Configuration @EnableScheduling public class SchedulConfig { } 2、编写定时任务业务

    package com.ecej.meterread.task.base.run; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; @Service public class Test { @Scheduled(fixedRate = 50000) public void testSchedul() { System.out.println("Test Schedul ..."); } }

    转载请注明原文地址: https://ju.6miu.com/read-14290.html

    最新回复(0)