1.@ConfigurationProperties(prefix = "mqtt") 将前缀mqtt的配置绑定到一个对象
@ConfigurationProperties(prefix = "mqtt") @Data public class ConnectProperties { public String host; public String username; public String password; private String[] topics; private int connectionTimeout; private int keepAliveInterval; private int reConnectSleepTime; }
2.@EnableConfigurationProperties(ConnectProperties.class) 激活这个配置类 相当于@Component
3.@ConditionalOnProperty(value = "mqtt.enable",havingValue = "true") 是否让Spring启用这个配置 havingValue =true时启用
4.