Spring Cloud Configuration Server not working with local properties file

后端 未结 9 2195
渐次进展
渐次进展 2020-12-05 07:43

I have been playing around with the Spring Cloud project on github located here: https://github.com/spring-cloud/spring-cloud-config

However I have been running into

9条回答
  •  南笙
    南笙 (楼主)
    2020-12-05 08:43

    All my code is here https://github.com/spencergibb/communityanswers/tree/so27131143

    src/main/java/Application.java

    @Configuration
    @EnableAutoConfiguration
    @EnableConfigServer
    public class Application {
    
        public static void main(String[] args) {
            SpringApplication.run(Application.class, args);
        }
    }
    

    src/main/resources/application.yml

    spring:
      application:
         name: myconfigserver
      profiles:
         active: native
    
    my:
      property: myvalue
    

    src/main/resources/myapp.yml

    my:
      otherprop: myotherval
    

    To get the properties for an app named myapp, do the following.

    curl http://localhost:8080/myapp/default

    {
         "name": "default",
         "label": "master",
         "propertySources": [
              {
                    "name": "applicationConfig: [classpath:/myapp.yml]",
                    "source": {
                         "my.otherprop": "myotherval"
                    }
              },
              {
                    "name": "applicationConfig: [classpath:/application.yml]",
                    "source": {
                         "spring.application.name": "myconfigserver",
                         "spring.profiles.active": "native",
                         "my.property": "myvalue"
                    }
              }
         ]
    }
    

提交回复
热议问题