Search code examples
spring-cloudspring-cloud-config

Consuming Properties at Spring Config Client


Is there way or reference materials on accessing properties exposed in Spring Cloud Config server at client? I know using @Value, I can get value for one element. Is it possible to extend or write a framework which can act as layer to consume all such properties and works as bridge to connecting applications.


Solution

  • Using below Annotations and Configurations

    @Configuration
    @EnableConfigurationProperties
    @ConfigurationProperties(prefix = "your.properties.")
    @RestController
    public class YourController{
    
    private <dataType> <variableName>
         /* Dont forget to generate setters and getters as this is bean */
    
    }
    

    Found solution @spencergibb link and other SO links