java中使用@ConfigurationProperties与@PropertySource时由于属性名与文件项字段名不一致导致无法注入自定义property配置文件问题
1. 问题描述:
本人想通过读取dir-map.properties自定义配置文件中的配置项,采用@ConfigurationProperties与@PropertySource组合的形式读取,结果发现无法将配置项的内容读取到RestartDirectoryConfig配置类中,尝试后发现是由于由于属性名与文件项字段名不一致导致,故记录下。
dir-map.properties自定义配置文件如下:
check.path-map[0].pdaadutDir=E:/project_files/ctm01scdk
check.path-map[0].stopDir=E:/project_files/ctm01scdk
check.path-map[0].startDir=E:/project_files/ctm01scdk
check.path-map[1].pdaadutDir=E:/project_files/ctm01scdk
check.path-map[1].stopDir=E:/project_files/ctm01scdk
check.path-map[