2017  Kodetalk | Feedback | Privacy Policy | Terms | About

Configure or getting properties file in spring controller from classpath

Need to configure or get a properties file using spring from classpath. How to get it?


Lets say you have a properties file in your classpath as below

// test.properties
test.test1 = Data
test.test2 = new data
test.test3 = 12

And to get the key value using spring try below way

public class TestProperties {

   private String test1;

   private String test2;

   private int test3;

   // all getters and setters
Answer is