首页 > 编程知识 正文

局部是指哪里,java读取外部配置文件

时间:2023-05-06 19:17:20 阅读:145238 作者:4500

@ConfigurationProperties默认从全局配置文件(application.properties/application.yml )获取值,

所有配置数据都写在全局配置文件中,太庞大了,可以提取并放入其他本地配置文件中

1 .将全局配置文件中的emp相关配置数据提取到resources/emp.properties文件中

2.@属性来源:加载指定的配置文件; value属性是数组类型,用于指定文件的位置

@ property source (value={ ' class path : EMP.properties ' } ) componentpublicclassemp { privatestring last name; 私有集成器Age; 私有双销售; 私密布尔总线; 私人日期比利特日; 私有地图; 私有列表; 私密格式; @Override public String toString () return'EMP ) ' ' lastname=''lastname'' ',age=' age ',salary=' salary biby } public String getLastName () { return lastName; } publicvoidsetlastname (string last name ) { this.lastName=lastName; }公共integer get age () { return age; }公共语音设置(integer age ) { this.age=age; }公共双获取salary () { return salary; } publicvoidsetsalary (双销售) { this.salary=salary; }公共布尔获取boss (() { return boss; } publicvoidsetboss (布尔总线) { this.boss=boss; }公共数据获取birthday () { return birthday; } publicvoidsetbirthday (date birthday ) { this.birthday=birthday; }公共映射get map () { return map; } publicvoidsetmap (映射图) { this.map=map; }公共列表getlist () { return list; }公共语音集列表(列表列表) { this.list=list; }公共格式获取() {返回格式; } publicvoidsetforte (格式) { this.forte=forte; }} emp.properties文件配置

编辑emp的数据emp.last-name=美丽氛围EMP.age=30 EMP.birthday=1989/9/12e MP.boss=false EMP.salary=23000 EMP.map

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。