@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