Read Properties Spring Application Context

Read Properties Spring Application Context

There are many ways you could read value from properties file while using Spring framework. If you want to read properties from file during Spring context load please use below simple technique. To make something working I will create small maven project to show how to read properties from file:

  • Create maven project name: LoadPropertyFromContext as full structure shown below:

Read Properties Spring Application Context

This is just for reference you could download full project from bottom download link.

  • Create properties file where you want to save all your project properties and in my case its where I wanted to save all my Solace properties:

  • spring-context.xml:

  • Create class to hold whatever properties are needed to use during Application context load:

  • Now create file which will load context and read properties:

Leave a Reply

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

I am not Robot *