I want to deploy my spring boot in a distributed environment. In general what is the best practise followed?
1.Each node of distributed environment having its own application.properties
2.All nodes of distributed environment sharing one application.properties
It is my first spring boot project, please dont kill me for this question :P
Many options are possible depending on your needs, some are trivial, others are more complicated but more flexible.
For the beginning, you can keep the configuration inside the spring boot application, not the ideal way of course, but its dead simple. You can place application-local.properties, application-production.properties, etc inside your resources folder and run the spring boot application with active profiles for the environment you need.
Another, more advanced setup is using the configuration file but keeping it outside the application.
Here you'll deploy this configuration file separately from the application, and here many options possible, including shared filesystems, automatic deployment, etc.
You can run spring boot application with --spring.config.location=<path to configuration file>
Now if you want to keep configurations in a git repository or filesystem and you have many microservices in your organization, managing them becomes a mess. So in this case, you can check configuration servers. Spring boot comes integrated with configuration server which is a part of spring cloud project. You can find here more information.
This is by far the most advanced setup - you can even change configurations dynamically and not restart the spring boot microservices (google for Refreshable beans in spring boot configuration). Moreover you can keep the configuration in git repository and it will automatically be able to work with it.
There are other solutions, maybe less integration with spring boot applications, but can be considered if you already use them in your organization: etc.d, consul, and so forth.
Usually, people when entering spring boot world start with the first or second option and then adopt the third option of one of its alternatives.