1

I need to build includes of properties from other files in Spring boot on loading the app. Does Spring Boot provides anything like this?

application.properties

external_source_environment = classpath:source_UAT1.properties
//external_source_environment = classpath:source_PROD1.properties

source_UAT1.properties

source.url = http://oneexample_uat1.com
source.credentials = abc/cdw

source_PROD1.properties

source.url = http://oneexample_uat2.com
source.credentials = aaa/bbb

So in the code, I could just refer to properties name, while be able to switch the active file only (profiles won't work, since they are used for specifying environment where code is running, not selection between sources within already selected env):

@Configuration
public class Source {
  @Value("${source.url}")
  private String url
}
glaz666
  • 8,707
  • 19
  • 56
  • 75
  • Does this answer your question? [How to add multiple application.properties files in spring-boot?](https://stackoverflow.com/questions/33229793/how-to-add-multiple-application-properties-files-in-spring-boot) – OrangeDog Oct 28 '20 at 12:52
  • Also, yes profiles will work. You have two profiles there `UAT1` and `PROD1`. – OrangeDog Oct 28 '20 at 12:54
  • how do I enable profile based on other property value? @OrangeDog – glaz666 Oct 28 '20 at 15:00

0 Answers0