We have a Spring-Boot Web application currently deployed to 7 environments (DEV, SIT, UAT, Pre-Prod, Prod, etc.). This application connects to other REST services, which has different URLs for each of 7 environments and are maintained in environment specific property file for our application.
We are planning to reduce number of environments to 3 (DEV, Staging, Prod) for our application. So, in the non-prod environments, the consumers of our application will call staging environment of our app and pass an additional header in request telling us which environment they are calling from.
And, our app should call other REST service URLs specific to environment header in request.
I was thinking, we can create beans for each of the REST endpoints for each environment - for eg UserServiceDev, UserServiceUat, etc. And we create a factory class where these beans will be injected and based on the environment header, it can return appropriate bean.
But this will involve replacing all injected service beans with infecting beans of this factory and will require changes to lot of files.
Is there any easier and cleaner way to do this?