Spring boot Could not locate PropertySource: label not found

Viewed 26663

I am trying set Spring Cloud Config Server, but the service config server, it the running on port 8888 which is correct, and another service should run on port 18060, but for reason when I startup, it allocate port 8080 for me and the return a warning "Could not locate PropertySource: label not found", what should I do? Thank you !!!

6 Answers

Add @EnableConfigServer at configuration class level or main class of spring boot application and restart the service .it will work .

In my case it was because I had to set the default branch of my github URI (the branch of the repository set for spring.cloud.config.server.git.uri) in the config server by setting the following to the application.properties

spring.cloud.config.server.git.default-label=main

I ran into similar issue, when I run my server locally I see in the logs only on the stratup

o.s.c.c.c.ConfigServicePropertySourceLocator - Could not locate PropertySource: label not found

It turned out this is a problem with the health check for the config server, when health check is triggered to config server an empty environment is used so the application name is empty hence the spring cloud client will try to access {config-server}/application since application is the default application name, see issue for more info on this.

To solve the issue I just disabled the health check for config server

health.config.enabled=false

In your bootstrap.yml file Add these lines

spring:
  cloud:
    config:
      enabled: true
      uri: http://localhost:8888 ##this is the link to the server config
      label: main ##this is what you are missing (name of the git repo branch)
  application:
    name: currency-spring-cloud-config-client
  profiles:
    active: testing


server:
  port: 8600
spring:
  cloud:
    config:
      enabled: true
      uri:
        - http://localhost:9196   ### your port for cloud config server
      label: main                 ### your git repo branch name
Related