0

I want to read Spring's boot active application.properties file a jar file that I add as Maven dependency. We mange environment params via 3-4 files under publish folder, for example:

-publish
 --some.project-application.properties.test
 --some.project-application.properties.dev

in the project root so I cannot use PropertySources(different file name per env). So is there is a way to read the active(in use) application.properties file? Is using @Value annotation will work without any configuration?

Itsik Mauyhas
  • 3,824
  • 14
  • 69
  • 114
  • Check out [Spring Profiles](https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-profiles.html). With an _application-dev.properties_ and and an _application-prod.properties_ file, a JVM parameter of -Dspring.profiles.active=dev, the application-dev.properties file will be used. So there is no change to the build process based on environment. The environment itself (the shell script starting the app) knows which profile to use. – Andrew S Feb 27 '19 at 13:23

1 Answers1

0

I think you should use spring naming conventions(application.properties, application-dev.properties), so that spring will automatically take the correct property file from the class path.

Also, refer : How to resolve placeholder in properties file with values from another properties file in spring boot application

Abbin Varghese
  • 2,422
  • 5
  • 28
  • 42