springboot 在配置文件写参数注入到类中
2024-08-25 00:46:21
@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
最新文章
- PB12.5.2安装
- 在osx下通过vmware无GUI方式运行centos 7
- 前端排版-使用inline-block且两端对齐
- 封装jquery时用到的东西
- python解析页面上json字段
- ZOJ-2587-Unique Attack(最小割的唯一性)
- 【递推】【HDU2585】【hotel】
- iOS中常见的锁
- 我的第一个python web开发框架(18)——前台页面与接口整合
- WireShark捕获HTTPS
- Windows下的wget,命令行下载url
- vue 在全局设置cookie main.js文件
- ElasticSearch入门2: 基本用法
- (改进)Python语言实现词频统计
- C++ stringstream格式化输出输入探索
- 重写Checkbox 改写选择框的大小
- Linux stat命令详解
- Centos简介
- 用C#写一个实现进程监控的自动关机工具
- 基于Nginx+FastDFS搭建图片文件系统
热门文章
- Django中ORM对数据库的增删改查操作
- win10配置 samba
- System.exit(0)和System.exit(1)区别(转)
- GIL - global interpreter lock
- UE格式化XML文件
- Codeforces Round #499 (Div. 2) Problem-A-Stages(水题纠错)
- PAT甲级——A1154 VertexColoring【25】
- docker 安装 lnmp
- maven项目中 把依赖的jar包一起打包
- Python- 接口类-抽象类