Quantcast
Channel: Active questions tagged config - Stack Overflow
Viewing all articles
Browse latest Browse all 5054

spring cloud config client not loading configuration from config server

$
0
0

I am following this link:http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html#_client_side_usage

I tested this again and again and not seeing Spring cloud client is loading configuration from cloud server, please help to see where is the error:

POM:

<dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency></dependencies>

Application:

@Configuration@EnableAutoConfiguration@RestControllerpublic class ConfigclientApplication {    @Value("${spring.cloud.config.uri}")    String url;    @Value("${production.host}")    String host;    @RequestMapping("/")    public String home() {        return "Host is  => " + this.host ;    }    public static void main(String[] args) {        SpringApplication.run(ConfigclientApplication.class, args);    }}

bootstrap.properties:spring.cloud.config.uri=http://localhost:8888

  1. The config server is good:http://localhost:8888/spirent/default
{"name": "spirent","profiles": ["default"  ],"label": "master","propertySources": [    {"name": "classpath:/spirent.yml","source": {"production.host": "server1","production.port": 9999,"production.value1": 12345,"test.host": "server2.com","test.port": 4444,"test.value": "hello123"      }    }  ]}
  1. now http://localhost:8080/ can not be started at all.

    Error creating bean with name 'configclientApplication'It seemed the auto inject of @Value can not find the production.host environment value.

How can I read the configuration in client once loaded from config server?

Thanks for your help.


Viewing all articles
Browse latest Browse all 5054

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>