为了账号安全,请及时绑定邮箱和手机立即绑定

从 Classpath 而不是从 resources/config.properties 中检索属性

从 Classpath 而不是从 resources/config.properties 中检索属性

qq_遁去的一_1 2021-06-21 17:12:32
我目前有以下方法,它允许我选择在我的 resources/config.properties 文件中定义的属性private final Properties properties = new Properties();{    final ClassLoader loader = getClass().getClassLoader();    try(InputStream config = loader.getResourceAsStream("Resources/config.properties")){        properties.load(config);    } catch(IOException e){        throw new IOError(e);    }}但我现在想从类路径中选择我的属性,所以我从资源中移动了我的 config.properties 并将它直接放在 src 下。但是我很难知道我现在需要对我的方法进行哪些更改才能从类路径中读取。
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 251 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号