一 .多个字段从配置文件中读取案例
1 java代码实现案例
package com.tsit.common.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@Data
@ConfigurationProperties(prefix = "platform")
public class ConfigProperties {
//应用id
private String appId;
//组织id
private String organId;
//应用密钥
private String appSecret;
//查询接口地址
private String url;
//查询多设备统计
private String url1;
}
2 配置文件中的案列
platform:
# 应用ID
appId: ${appId:hpzLo6Lo}
organId: ${organId:3701020101000181}
# 应用密钥
appSecret: ${appSecret:36a4f404fb49e2aad036fb90b64751f3af9ab212}
# 工业互联网域名
# url: ${platformUrl:http://ipo.ts-it.cn}
url: ${platformUrl:https://industry-manage-test.ts-it.cn/iotm/open/data/deviceByPage}
url1: ${platformUrl1:https://industry-manage-test.ts-it.cn/iotm/open/data/multi_device