-2

I have very generic question, how spring boot understands that it should read values from application.properties? What will happen if I rename it to some xyz.properties? And, How it intelligently able to distinguish different files (application-dev.properties, application-qa.properties etc)? What exactly is happening behind the scene?

implosivesilence
  • 536
  • 10
  • 24

2 Answers2

1

How spring boot understands that it should read values from application.properties?

It understands that because the developers of Spring wrote code to specifically look for a file by that name, as documented in the Application Property Files section of the Spring Boot Reference Documentation.

What will happen if I rename it to some xyz.properties?

Then the file will not be loaded, unless you add code to cause it to be loaded, e.g. using @PropertySource.

How it intelligently able to distinguish different files (application-dev.properties, application-qa.properties etc)?

Spring Boot was coded to look for profile-specific property files for active profiles, as documented in the Profile-specific Properties section of the Spring Boot Reference Documentation.

What exactly is happening behind the scene?

That is too broad a topic to cover here. As suggested by takendarkk, the Spring Boot code is open source so you can just look into it to see what it does and how.

Andreas
  • 154,647
  • 11
  • 152
  • 247
0

Spring maintain order to load property files. please refer to this answer for more details

alvinmeimoun
  • 1,472
  • 1
  • 19
  • 38