1. 程式人生 > >springboot 在配置檔案寫引數注入到類中

springboot 在配置檔案寫引數注入到類中

@Configuration
//配置檔案位置
@PropertySource("classpath:city.properties")
//字首
@ConfigurationProperties(prefix = "city")
public class CityProperties {

private Map<String,Integer> map = new HashMap<>();

public Map<String, Integer> getMap() {
return map;
}

public void setMap( Map<String, Integer> map) {
this.map = map;
}
}


city.map.V0441201=350
city.map.V0350600=351
city.map.V0520100=358
city.map.V0441800=363
city.map.V0330100=373
city.map.V0430400=374
city.map.V0130600=390