0

I'm developing an API which will connect with several endpoints. The uri for each endpoint is something like this:

rest/services/General/directory1/MapServer/export
rest/services/General/directory2/MapServer/export
rest/services/General/directory3/MapServer/export
rest/services/General/directory4/MapServer/export

and so on...

I don't know if it's possible, but would like to have something like this instead:

rest/services/General/${value}/MapServer/export

and then on my code just call the endpoint above injecting the specific directory that I want on ${value}

Is it possible? Don't know what I'm missing as I googled but couldn't find anything related.

Cheers

Rafael Paz
  • 497
  • 7
  • 22
  • You can use maven profiles. set maven property on profile generate different flover. https://maven.apache.org/guides/introduction/introduction-to-profiles.html – Himeshgiri gosvami Jan 04 '19 at 07:58

2 Answers2

1

You can do so by means of Spring Cloud Config.

Spring Cloud Config provides server and client-side support for externalized configuration in a distributed system. With the Config Server you have a central place to manage external properties for applications across all environments. The concepts on both client and server map identically to the Spring Environment and PropertySource abstractions, so they fit very well with Spring applications, but can be used with any application running in any language. As an application moves through the deployment pipeline from dev to test and into production you can manage the configuration between those environments and be certain that applications have everything they need to run when they migrate. The default implementation of the server storage backend uses git so it easily supports labelled versions of configuration environments, as well as being accessible to a wide range of tooling for managing the content. It is easy to add alternative implementations and plug them in with Spring configuration.

For more details, kindly go through spring documentation here.

Dark Knight
  • 8,218
  • 4
  • 39
  • 58
  • cheers for the reply. Will have a look now, but I would like to use just spring boot if possible as I'm working for a client and the project was handled to me by them, and all the dependencies of the project it's stored by them, meaning I don't have direct access to them. They want like that, so if possible I was looking for just spring boot, but will have a look and see if I can do it. Cheers for taking the time to help :) – Rafael Paz Jan 04 '19 at 06:19
  • 1
    May be this post is what you are looking for https://stackoverflow.com/questions/40287771/how-to-reload-a-value-property-from-application-properties-in-spring – Dark Knight Jan 04 '19 at 06:50
  • Thanks mate for helping out, but I just decided to use the simplest approach: string.replace(). Just thought would be much of trouble to implement this using spring cloud. – Rafael Paz Jan 04 '19 at 07:20
  • 1
    For scenario ahead of you, what you said seems relevant. – Dark Knight Jan 04 '19 at 07:58
0

I solve the problem using the simplest approach possible. In my code I used the string.replace() method. Was looking for something more robust, but as it was taking lots of time to sort it out how to do it, I decided to go with the string.replace method.

Rafael Paz
  • 497
  • 7
  • 22