How to Read key value from .properties file in Spring

Connect with

Spring FrameworkReading single .properties file or multiple properties file in spring is very easy and it can be done by different way. I’m going to demonstrate by using basic bean configuration.

We can use PropertyPlaceholderConfigurer class which contains in spring core module itself.

Properties file file:

2. Single properties file in xml meta data configuration

If you have single properties file, you have to user location property of PropertyPlaceholderConfigurer class.



3. Multiple properties file

If you have multiple properties file , you have to user locations property of PropertyPlaceholderConfigurer class. If .properties file outside of your application you can use absolute path with prefix as file:. If within you application you can use classpath: prefix in you location. You can use locations property as well if you have only one .properties file.


Your comments are welcome. Happy Learning 🙂

Connect with

Leave a Reply

Your email address will not be published. Required fields are marked *