示例一
String path = FlywayMigration.class.getResource("/").getPath() + "flyWay.properties";
path = URLDecoder.decode(path, "utf-8");
Resource resource = new FileSystemResource(path);
Properties configs = PropertiesLoaderUtils.loadProperties(resource);
第一行 FlywayMigration 为当前类名称
最后一行 PropertiesLoaderUtils 为 springframework 提供的加载工具类,也就是spring 框架提供
示例二
Java专题 类加载器获取文件流,转properties并获取的内容,以及读取线程锁
示例三
当使用 springboot 框架时 读取配置文件中的属性 使用
@Value("${proName}")
proName 为 在 springboot 指定的配置文件 application.properties 中自己定义的属性名