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
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: 8888
endpoints:
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-service
cloud:
config:
uri: http://localhost:8888
The config server will read the local properties files if the application.properties
of config server contains:
spring.profiles.active=native
**spring.cloud.config.server.native.searchLocations=file:/source/tmp**
at /source/tmp
directory, you store the local property file for client, for example:
http://localhost:8888/a-bootiful-client/default
you will get:
{"name":"a-bootiful-client","profiles":["default"],"label":null,"version":null,"state":null,"propertySources":[{"name":"file:/source/tmp/a-bootiful-client.properties","source":{"message":"Kim"}}]}
I was able to get it work with local repo and bootstrap configuration:
java -jar spring-cloud-config-server-1.0.0.M3-exec.jar --spring.config.name=bootstrap
The bootstrap.yml file is placed in ./config/ folder.
server:
port: 8080
spring:
config:
name: cfg_server
cloud:
config:
server:
git:
uri: /home/us/config_repo
searchPaths: pmsvc,shpsvc
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/config
spring.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
I had the same problem when running the Configuration Server in Mac OS environment. This did not happen in Linux or Windows.
I had the native property set in the bootstrap.yml
file like this:
spring:
profiles:
active: native
Finally the way it worked for me on the mac was to pass the active profile to the jar file, like this.
java -jar config-server.jar --spring.profiles.active=native
I still don't know why it behaves differently in Mac OS.
I've had this issue on Mac when there is a space in a path to a file:
spring.cloud.config.server.native.search-locations=file:///Users/.../Development/Folder with a space /prj
Also pay attention that there are 3 slashes before Users:
spring.cloud.config.server.native.search-locations=file:///Users/...
or I use:
spring.cloud.config.server.native.search-locations=file://${user.home}/Desktop
The native property is:
spring.profiles.active=native