Spring Cloud Configuration Server not working with local properties file Spring Cloud Configuration Server not working with local properties file spring spring

Spring Cloud Configuration Server not working with local properties file


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

src/main/java/Application.java

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

src/main/resources/application.yml

spring:  application:     name: myconfigserver  profiles:     active: nativemy:  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"                }          }     ]}


I am able to read configuration for apple-service(Test Micro Service) using Spring config server.

Example application.yml of spring config application

spring:    profiles:        active: native    cloud:        config:            server:                native:                    searchLocations: classpath:config/server:  port: 8888endpoints:    restart:      enabled: true

Put your .properties or .yml files inside src\main\resources\config folder. Make sure name of this files should match spring.application.name of your micro service.

For example if spring.application.name=apple-service then property file should be apple-service.properties in src\main\resources\config folder.

Example bootstrap.yml of apple-service:

spring:  application:    name: apple-servicecloud:  config:    uri: http://localhost:8888


Here is what I did:

following https://medium.com/@danismaz.furkan/spring-cloud-config-with-file-system-backend-c18ae16b7ad5

1) !!dont forget your VM options!!:

-Dspring.profiles.active=native

(in Netbeans : configserver->project->properties>Run->VM options

2) Either in application.properties

#spring.cloud.config.server.native.searchLocations=file:///C:/tmp/configspring.cloud.config.server.native.searchLocations=classpath:/config

or applications.yml

spring:    cloud:         config:            server:                native:                    search-locations  : file:///C:/tmp/config                    #search-locations : classpath:/config

Notes:

n1: search-locations and searchLocations both work

n2: file:/// => hard file path

Like

c:/temp/config/           app-admin.yml           app-admin-develop.yml           .... 

n3: for your profile config files

classpath:/

Like

Other sources/src/main/resources/config/app-admin.yml

n4: I couldnt made file paths work without setting the vm options. Dont forget! Just setting spring.profiles.active=native in your application config does not do the trick for me

n5: example http queries

http://localhost:8998/app-admin/default/yml

gives app-admin.yml

http://localhost:8998/app-admin/develop/yml

gives app-admin-develop.yml