road-network-renovation:
problem:
"[demo]": stop_time
"[测试]": queue
ProblemVo:
- name: demo
index: rate
space: 流向
- name: 测试
index: queue
space: 进口
这是配置文件,problen是注入map(problem的key要加[]不然的话编译会报类型转换错误),ProblemVo是注入bean的,-代表数组的元素
@Configuration
@ConfigurationProperties(prefix = "road-network-renovation")
@Component
@PropertySource(value = {"classpath:/application.yml"}, encoding = "utf-8")
@Data
public class ProblemConfig {
private Map<String, String> problem;
private List<ProblemVo> ProblemVo;
}
需要写一个配置类,属性名称要和配置的名称相同。
@Autowired
ProblemConfig problemConfig;
在service层这样去调用。