首先在先配置如下代碼(紅色框里是獲取文件的名稱) 然后再java類(lèi)里加@Value("#{configProperties.sonsCount}")注解再定義private int sonsCount;變量即可。