Reputation: 844
Currently I inject to my application properties via @Value and it works just fine. Now I want my application to support more than one configuration, which means its @Value should return different value each time.
I read about spring profiles, but I couldn't understand how can I switch profile on runtime. Is it even possible?
What I really need is to load all of the configuration when the server starts and choose its profile dynamically when a request arrives - each request should have one set of configurations.
Upvotes: 5
Views: 7089
Reputation: 2521
Switching Spring profiles during runtime is not a good practice. Spring profile is meant to be used as a way to manage your application across different environments.
Spring Profiles provide a way to segregate parts of your application configuration and make it be available only in certain environments
If you have a variable that needs to change dynamically for every incoming requests, consider these several options:
Upvotes: 9