I have a java maven project. i have placed a properties file in src/main/resources
folder.
src/main/resources
|
|___properties
|
|
|___custom_en_US.properties
I am loading properties file as below in servlet.
ResourceBundle bundle = ResourceBundle.getBundle("classpath:properties/custom", request.getLocale());
but above line is throwing exception saying resource not found. How can i give path to properties file? Please help me.
Thanks!
Get rid of the "classpath" prefix.: .getBundle("/properties/custom")
The "classpath" prefix is not a standard, it is defined by some frameworks like spring.
Read the property file from classpath
Properties prop = new Properties();
try {
//load a properties file from class path, inside static method
prop.load(App.class.getClassLoader().getResourceAsStream("config.properties"));
} catch (IOException ex) {
ex.printStackTrace();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With