标题 IO - Properties加载资源
今天加载资源遭遇了问题,顺便总结一下。 先贴上我知道的三种加载方式,当然现在的框架里会有各种注解加载。学习这种方式便于了解本质。
/**
* @author lct
* @version 1.0: loadProperties, v 0.1 2021-07-12 17:11 lct Exp $
*/
public class FileStreamLoadProperties {
public static void main(String[] args) throws IOException {
FileReader fileReader = new FileReader("src/main/resources/application.properties");
Properties properties = new Properties();
properties.load(fileReader);
System.out.println(properties.get("spring.datasource.username")