Spring Boot @ConfigurationProperties 配置绑定
Jihongchang(讨论 | 贡献)2023年2月13日 (一) 05:42的版本
https://www.bilibili.com/video/BV19K4y1L7MT/?p=12
旧的 properties 文件参数读取封装到 Java Bean
public class getProperties {
public static void main(String[] args) throws IOException {
Properties pps = new Properties();
pps.load(new FileInputStream("a.properties"));
Enumeration<?> enumeration = pps.propertyNames(); //得到配置文件的名字
while (enumeration.hasMoreElements()) {
String strKey = (String) enumeration.nextElement();
String strValue = pps.getProperty(strKey);
System.out.println(strKey + "=" + strValue);
/**
* 封装到 Java Bean
* ……
*/
}
}
}