package com.xydl.util; import com.xydl.service.impl.MqttServiceImpl; import lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; import java.text.SimpleDateFormat; import java.util.Date; @Component @Slf4j public class Subscribe { @Autowired MqttUtil mqttUtil; private static Subscribe single = new Subscribe(); @PostConstruct private void SubscribeMqtt() { // log.info("开始订阅===subScribe执行一次==={}", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); // mqttUtil.subScribeMQTT(); } public static Subscribe getInstance() { return single; } }