java.util.MissingResourceException: Can't find bundle for base name 'property_file name', locale en_US

后端 未结 9 1867
失恋的感觉
失恋的感觉 2020-12-09 07:30

I am trying to create a utility class ReadPropertyUtil.java for reading data from property file. While my class is located under a util directory , my sky

9条回答
  •  感动是毒
    2020-12-09 08:30

    The simplest code would be like, keep your properties files into resources folder, either in src/main/resource or in src/test/resource. Then use below code to read properties files:

    public class Utilities {
        static {
            rb1 = ResourceBundle.getBundle("fileNameWithoutExtension"); 
                  // do not use .properties extension
        }
        public static String getConfigProperties(String keyString) {
            return rb1.getString(keyString);
        }
    }
    

提交回复
热议问题