Load Properties File Spring Config

Load Properties File Spring Config

If you are using Spring framework in your application and want to load complete properties file through class constructor through XML file configuration please use below code.

Note: Your properties file should be in classpath

  • To better understand please have a look below maven project:

Load Properties File Spring Config

  • As you see above we have DEV.properties file as below:

  • LoadPropertiesFile.java:

  • pom.xml:

  • spring-context.xml:

Test java class to load Spring context and read properties from file:

  • LoadApplication.java:

  • Output:

Load Properties File Spring Config

  • For more information please visit Spring documentation here

download Download Project:  LoadProperitesFileXMLConfig

Leave a Reply

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