@Configuration @EnableScheduling public class ScheduleConfig { private final Logger logger = LoggerFactory.getLogger(ScheduleConfig.class); @Autowired private SBUXPingService sbuxPingService; @Scheduled(cron = "0/10 * * * * ?") // 每10秒执行一次 public void scheduler() { if (sbuxPingService.schedulePing()) { logger.error("============== 定时Ping成功 ==============="); } else { logger.error("============== 定时Ping失败 ==============="); } } }