Maven结构下 properties 读取

Properties properties = new Properties();
InputStream in = ClassLoader.class.getResourceAsStream("/config/application-time.properties");
if (in == null) {
in = XXX.class.getClassLoader().getResourceAsStream("/config/application-time.properties");
}
if (in == null) {
throw new RuntimeException("读取配置文件config/
application-time..properties失败");
}

properties.load(in);
in.close();
properties.getProperty("server.port");
posted @ 2017-03-30 15:05  旋转的梦  阅读(663)  评论(0编辑  收藏  举报