【Java.bug】(1)Can‘t find bundle for base name xxx, locale zh_CN

268 阅读1分钟

问题出现可能原因:

  • 路径没写对
  • 路径没错,加了不该加的拓展名

问题代码:

ResourceBundle bundle = ResourceBundle.getBundle("resource.properties");

出现问题:

在这里插入图片描述

原因:

使用资源文件时,不能带拓展名 .properties

正确写法:

ResourceBundle bundle = ResourceBundle.getBundle("resource");

每天进步一点点(IceClean)