0

Am looking to pass variables at run time once war file is deployed on tomcat .. How can i use application.properties whcih is in classplath along with another properties file ex. abcd.properties located at particular directory..Am basically looking to set additional classpath and read value from properties file in that path along with default classpath location for war deployment.

Am using Spring boot .One of the way is to pass all properties to database end , but am looking for a file based i.e properties based workout. (Having multiple applications on same tomcat instance.)

Sanjay A
  • 316
  • 3
  • 15
  • Possible duplicate of [Spring boot external configuration of property file](https://stackoverflow.com/questions/43020491/spring-boot-external-configuration-of-property-file) – Simion Aug 14 '18 at 17:00

1 Answers1

0
  1. Spring Boot App --> run as --> run configurations. Now here in VM arguments add Dproperties.location="Path of the properties".
  2. Now, in your Spring Boot application use the annotation @PropertySource("file:${properties.location}/propertiesfileName.properties") just above the class declaration.
  3. Autowire Environment in your class. use env.getProperty("propertyname").
  4. You can access the values from application.properties as usual using @Value annotation. Hope this helps.
Jay
  • 132
  • 1
  • 4