1

I have a dead simple config server with following properties :

spring:
    profiles:
        active: native
    cloud:
        config:
            server:
                native:
                    searchLocations: classpath:/configs
server:
    port: 8888

In the src/main/resources folder i have a configs folder with a customer-service.yml file inside it containing the following config :

spring:
    application:
        name: customer-service
    h2:
        console:
            enabled: true
server:
    port: 8080
eureka:
    client:
        serviceUrl:
            defaultZone: ${EUREKA_URI:http://localhost:8761/eureka}
    instance:
        preferIpAddress: true
        leaseRenewalIntervalInSeconds: 1
        leaseExpirationDurationInSeconds: 2
logging:
    level:
        com.netflix: WARN

The config server starts with no issue but issuing the following URL in the browser - http://localhost:8888/customer-service/master - returns the following response :

{"name":"customer-service","profiles":["master"],"label":null,"version":null,"state":null,"propertySources":[]}

There doesn't seem to be many examples out there of using a folder on the classpath to store configs. What am I doing wrong?

Martin
  • 1,977
  • 5
  • 30
  • 67
  • What is the server response using http://localhost:8888/customer-service/default or just http://locahost:8888/customer-service ? I never used a native config server but it seems that labels work different in this situation. There is also a property that allows you to remove label locations which could be helpful: `spring.cloud.config.server.native.addLabelLocations=false` – Dan_Maff Feb 27 '19 at 19:32
  • /default gives me the same exact response except with default in the profile tag and / gives me a 404 error – Martin Feb 27 '19 at 19:46
  • The second parameter is profile. What does the listing under configs look like? – spencergibb Feb 27 '19 at 20:00
  • i put the customer-service.yml file directly in the configs folder – Martin Feb 27 '19 at 20:03
  • 2
    @Martin I just tried your setup and I don't see it. What version of Spring Boot are you using? I tried it both in my IDE and running the jar. Using /default or /master returns the property sources for me. – Hermann Steidel Feb 27 '19 at 20:46
  • eclipse auto-generated a project with spring boot 2.2 snapshot as the parent version, i just changed it to 2.1.3 release (as my other services are) and it's working now! ¯\_(ツ)_/¯ – Martin Feb 27 '19 at 20:50
  • @Martin, yes I also used 2.1.3 on a Spring Initialized project. There must be a bug or something is different in 2.2. – Hermann Steidel Feb 27 '19 at 20:50
  • please post an answer so i can accept it! Thanks! – Martin Feb 27 '19 at 20:51

1 Answers1

1

I just tried it with Spring 2.1.3 and it works as you have laid it out. Since you mentioned you are using Spring 2.2, there might have been a change or potentially a bug.

Update

Just for kicks, I tried it with 2.2.0.BUILD-SNAPSHOT and it works as well. Not sure what to say at this point.

Hermann Steidel
  • 1,000
  • 10
  • 18