通过PropertiesLoaderUtils类来读取
import org.springframework.core.io.support.PropertiesLoaderUtils;
Properties properties = PropertiesLoaderUtils.loadAllProperties("test.properties");
String test = properties.getProperty("test");
System.out.println("properties.test:"+test);
只有运行状态下才能读取,建立 main 方法运行为空

本文介绍如何使用Spring框架中的PropertiesLoaderUtils类来加载并读取配置文件内容。演示了加载test.properties文件并获取其中名为test的属性值的方法。
9736

被折叠的 条评论
为什么被折叠?



