spring cloud config client not loading configuration from config server

user3006967

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
@RestController
public 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.

RubesMN

As Deinum implies, I'd ensure you have the client configured with the parent as spring-cloud-starter-parent and give it a version. Maven plugins provided by spring cloud wont work when you include in your dependencies and remember cloud is a different project than boot. Change it to:

<parent>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-parent</artifactId>
    <version>1.0.0.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

Second, as a new discipline (and likely not your problem here), I'd use the new annotation on your Application instead of @Configuration and @EnableAutoConfiguration

@SpringBootApplication

Third, double check you have @EnableConfigServer on your config server

Fourth, be sure your bootstrap.properties on your client has your spring application name specified:

spring.application.name=spirent

Finally, if you used the spring-cloud-config example project, there is a default user and security password that you have to set in your URI:

http://user:ddf4757e-0077-42e4-b2ad-2ae04340b08c@localhost:8888

Otherwise, try starting from the spring-cloud-config project located here to ensure your config server is setup correctly:

https://github.com/spring-cloud/spring-cloud-config

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Modify spring cloud config server in the client

From Dev

Spring Cloud Config Client not fetching config when Spring Security is active on Spring Cloud Config Server

From Dev

Spring Cloud Config Client re-loading config every 30 seconds

From Dev

How to ask Spring Cloud Config server to checkout configuration from specific branch?

From Dev

Organizing large amounts of application configuration in Spring Cloud Config Server

From Dev

RefreshScope Runtime Configuration Without Spring Cloud Config Server

From Dev

What is the loading precedence for properties from Spring Cloud Config?

From Dev

How to config multiple Eureka Servers from client in Spring Cloud

From Dev

Exclude Spring Cloud Config Server from Spring boot unit test

From Dev

Externalizing Spring Cloud Data Flow Config - Spring Cloud Config Server

From Dev

Externalizing Spring Cloud Data Flow Config - Spring Cloud Config Server

From Dev

Save Properties Downloaded from Spring Cloud Config Server

From Dev

How to set system variable from Spring Cloud Config Server

From Dev

Share configuration between Spring cloud config clients

From Dev

Spring Cloud Config Server without Spring Boot

From Dev

Spring Cloud Config: How to refresh configuration after client has been started?

From Dev

Include common config for multiple apps in Spring Cloud Config server

From Dev

Spring Cloud Config: define server config properties programmatically

From Dev

Loading additional spring profiles from java config

From Dev

Spring Cloud Config Server - Security Details

From Dev

Spring Cloud Config Server - Placeholder Label

From Dev

Disable Spring Cloud Server Config using profile?

From Dev

Pattern matching for profile in Spring Cloud Config Server

From Dev

Spring Cloud Config Server plain text

From Dev

Spring Boot + Spring Cloud Config - How to add more profiles from the Git external configuration

From Dev

Configuring Spring Cloud Config Server and Spring Cloud Vault for production

From Dev

Spring Cloud Config Globals

From Java

Spring Cloud Config Server vs ConfigMaps for cloud kubernetes

From Dev

Spring Config Server Vault Backend: cloud.config.server.vault or cloud.vault

Related Related

  1. 1

    Modify spring cloud config server in the client

  2. 2

    Spring Cloud Config Client not fetching config when Spring Security is active on Spring Cloud Config Server

  3. 3

    Spring Cloud Config Client re-loading config every 30 seconds

  4. 4

    How to ask Spring Cloud Config server to checkout configuration from specific branch?

  5. 5

    Organizing large amounts of application configuration in Spring Cloud Config Server

  6. 6

    RefreshScope Runtime Configuration Without Spring Cloud Config Server

  7. 7

    What is the loading precedence for properties from Spring Cloud Config?

  8. 8

    How to config multiple Eureka Servers from client in Spring Cloud

  9. 9

    Exclude Spring Cloud Config Server from Spring boot unit test

  10. 10

    Externalizing Spring Cloud Data Flow Config - Spring Cloud Config Server

  11. 11

    Externalizing Spring Cloud Data Flow Config - Spring Cloud Config Server

  12. 12

    Save Properties Downloaded from Spring Cloud Config Server

  13. 13

    How to set system variable from Spring Cloud Config Server

  14. 14

    Share configuration between Spring cloud config clients

  15. 15

    Spring Cloud Config Server without Spring Boot

  16. 16

    Spring Cloud Config: How to refresh configuration after client has been started?

  17. 17

    Include common config for multiple apps in Spring Cloud Config server

  18. 18

    Spring Cloud Config: define server config properties programmatically

  19. 19

    Loading additional spring profiles from java config

  20. 20

    Spring Cloud Config Server - Security Details

  21. 21

    Spring Cloud Config Server - Placeholder Label

  22. 22

    Disable Spring Cloud Server Config using profile?

  23. 23

    Pattern matching for profile in Spring Cloud Config Server

  24. 24

    Spring Cloud Config Server plain text

  25. 25

    Spring Boot + Spring Cloud Config - How to add more profiles from the Git external configuration

  26. 26

    Configuring Spring Cloud Config Server and Spring Cloud Vault for production

  27. 27

    Spring Cloud Config Globals

  28. 28

    Spring Cloud Config Server vs ConfigMaps for cloud kubernetes

  29. 29

    Spring Config Server Vault Backend: cloud.config.server.vault or cloud.vault

HotTag

Archive