@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
另一种
@Value(value = "${R.host}")
public String Rhost;
@Value(value = "${R.port}")
public String Rport;
在application中写
R.host=localhost
R.port=6311