参考: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目录下】

始终提示找不到该文件

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

 

原因

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

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

 

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

解决方法

去掉properties后缀即可

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

 



 

相关文章:

  • 2022-01-12
  • 2022-12-23
  • 2021-10-12
  • 2021-12-24
  • 2022-12-23
  • 2021-07-23
  • 2022-12-23
猜你喜欢
  • 2021-07-31
  • 2021-12-14
  • 2022-12-23
  • 2021-11-04
  • 2021-07-29
  • 2022-12-23
相关资源
相似解决方案