// 不需要重启服务器
// Properties properties =
// PropertiesLoaderUtils.loadAllProperties("scheduleConfig.properties");
// System.out.println(properties.get("feeSplitingColletCorn"));
//java io文件流方式读取
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
URL resource = contextClassLoader.getResource("scheduleConfig.properties");
InputStream ins = new FileInputStream(resource.getPath());
Properties props = System.getProperties();
props.load(ins);
System.out.println(props.get("feeSplitingColletCorn"));
// 利用类加载器读取文件,不能动态加载properties 需要重启服务器.
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
InputStream resourceAsStream = classLoader.getResourceAsStream("scheduleConfig.properties");
Properties properties = System.getProperties();
properties.load(resourceAsStream);
System.out.println(properties.get("feeSplitingColletCorn"));
properties文件读取备忘
最新推荐文章于 2019-06-14 16:06:59 发布