我尝试加载属性文件时出现以下异常:
尝试使用绝对路径失败,将文件重命名为
Caused by: java.util.MissingResourceException: Can't find bundle for base name /fontawesome/fontawesome, locale en_US
我正在使用一个Maven项目,我的属性文件位于src\main\resources\fontawesome\fontawesome.properties
我正在使用以下代码从JavaFX8主类加载此文件:
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setResources(ResourceBundle.getBundle("/fontawesome/fontawesome.properties"));
尝试使用绝对路径失败,将文件重命名为
fontawesome_en_US.properties或fontawesome_en.properties 也无效(如其他SO帖子中所建议的)。
ResourceBundle
将使用没有后缀的文件作为默认文件,如果找不到一个具有匹配后缀的文件。这个回答 解释了为什么绝对路径也不起作用。 - xlm