配置application.yml文件
command:
config:
commands:
- serviceId: aaa
serviceParametersKey: http://www.baidu.com
serviceParametersValue: 4
commandType: 4
commandCode: 4
- serviceId: bbb
serviceParametersKey: http://www.baidu.com
serviceParametersValue: 5
commandType: 5
commandCode: 5
实体类:
import lombok.Data;
/**
* @author :Jinlong.Ma3
* Date : 2022/6/28 10:03:55
*/
@Data
public class Command {
private String serviceId;
private String serviceParametersKey;
private String serviceParametersValue;
private String commandType;
private String commandCode;
}
配置类:
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
/**
* @author :Jinlong.Ma3
* Date : 2022/6/28 10:02:40
*/
@Slf4j
@Component
@ConfigurationProperties(prefix = "command.config")
public class ConfigCommand {
public List<Command> getCommands() {
return commands;
}
public void setCommands(List<Command> commands) {
this.commands = commands;
}
/**
* 配置项列表
*/
private List<Command> commands = new ArrayList<>();
}