package com.nanjing.water.host.mqtt; import com.nanjing.water.common.config.MqttConfig; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; import java.util.Objects; @Component @Order(40) public class MQTTStart implements InitializingBean { @Autowired private MQTTSubsribe mqttSubsribe; @Autowired private MqttConfig mqttConfig; @Override public void afterPropertiesSet() throws Exception { if (Objects.equals(mqttConfig.getEnable(), Boolean.FALSE)) { return; } mqttSubsribe.init(); } }