Maven ResourceBundle.getBundle读取Properties异常MissingResourceException: Can't find bundlei解决方法...

 

参考:https://blog.csdn.net/thousa_ho/article/details/72817616

 

问题描述

ResourceBundle读取properties配置文件提示

MissingResourceException: Can not find bundle for base name resource.properties

reource.properties放在resources目录【classpath目录下】

始终提示找不到该文件

 

 

原因

classpath下的文件编译后放在classes目录下,与项目根目录同级!

 

ResourcesBundle如果读取的文件带有“properties”后缀名,则它会从工程根目录下找;而如果要到classes下去寻找,则要去掉后缀!

解决方法

去掉properties后缀即可

ResourceBundle resourceBundle = ResourceBundle.getBundle("resource", Locale.getDefault());

 



 

转载于:https://www.cnblogs.com/guyeshanrenshiwoshifu/p/9812708.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值