I've been looking for a way to change the url my microservice is depending on from one environment to another, they told me that I should use spring cloud, and there is currently an application.yml that is used for deployment in openshift, but my knowledge of Spring Cloud is limited and I don't know how to inject the value of the application.yml URL into my java program.
String uri = "http://127.0.0.1:8080/route";
I am looking to change this variable depending on whether it is local, or in development
Why? For communication between microservices
private RestTemplate call = new RestTemplate();
Arrays.asList(call.getForObject(uri, Object[].class));
In local need: "http://127.0.0.1:8080/route";
In dev need : "http://www.myurl.com/route"
I hope I explained myself well
Thanks.
Ok, i think have the solution for my problem. As I am using Openshift for deployments, and the local configuration for something else, I have used Spring Cloud with a configuration server, making it use one configuration locally, and in development another one overwriting the local configuration.
This solved my problem, thanks to other guys to answer with any solutions.