getResourceAsStream properties
2024-09-02 08:36:37
try (InputStream is = getClass().getResourceAsStream("/test.properties")) {
Properties properties = new Properties();
properties.load(is);
ps=new PropertiesPropertySource("main", properties);
} catch (IOException e) {
log.error("Something went wrong", e);
}
private String getPomPerpertiesPath() {
String classPath = getClass().getClassLoader().getResource("").getPath();
String aString = "classes/";
String targetPath = classPath.substring(0, classPath.lastIndexOf(aString));
StringBuilder sb = new StringBuilder();
sb.append(targetPath).append("maven-archiver/pom.properties");
return sb.toString();
}*/
private Properties getProperties(InputStream is) throws IOException {
Properties properties = new Properties();
properties.load(is);
log.info("All defined properties: {}", properties);
return properties;
}
private Properties getProperties(String fileName) throws IOException {
try (InputStream is = new FileInputStream(new File(fileName))) {
Properties properties = new Properties();
properties.load(is);
log.info("All defined properties: {}", properties);
return properties;
}
System.out.println(getClass().getClassLoader().getResource(""));
System.out.println(getClass().getClassLoader().getResource("").getPath());
System.out.println(getClass().getResource(""));
System.out.println(getClass().getResource("").getPath()); file:/C:/Users/lt32806/git/tempest/tempest-app/tempest-app-report/target/classes/
/C:/Users/lt32806/git/tempest/tempest-app/tempest-app-report/target/classes/
file:/C:/Users/lt32806/git/tempest/tempest-app/tempest-app-report/target/classes/com/citi/simpliciti/tempest/report/
/C:/Users/lt32806/git/tempest/tempest-app/tempest-app-report/target/classes/com/citi/simpliciti/tempest/report/ https://blog.csdn.net/wws921104/article/details/72637050/
http://riddickbryant.iteye.com/blog/436693
最新文章
- datatable-提示
- 转:Web应用程序项目XX已配置为使用IIS
- iOS 清理缓存功能的实现第二种方法
- Android 中获得notification的发出时间
- oracle11g导入到10g
- MVC 中使用扩展方法
- NaN属性,isNaN函数
- UVALIVE 3026 Period
- 范围for语句 &;&; 列表初始值&;&; 标准库函数begin和end
- hdu 2565 放大的X
- 获取控件id
- android: activity之间切换的抽屉效果
- iOS开发之应用程序启动图片规格
- jquery插件封装
- Spring Boot框架的自动配置
- Swift学习笔记6
- golang中的接口实现(二)
- bat批处理设置静态、动态、ping、查看网络配置
- Hibernate入门第二课 Hibernate Tools for Eclipse Plugins安装
- Spring Cloud(二):服务注册与发现 Eureka【Finchley 版】