spring cloud config server git for local file - spring

I want get the data from local file using spring cloud config server git.
I have tried with below Yaml config but it is not working.
server:
port: 8888
spring:
cloud:
config:
server:
git:
uri: file:///C:/spring-boot-ws/demo-springcloud-m2-configserver-git/pluralsight-spring-cloudconfig-wa-tolls-master/
My folder Structure is like
C: > spring-boot-ws > demo-springcloud-m2-configserver-git > pluralsight-spring-cloudconfig-wa-tolls-master > station1 > s1rates.properties

As its name suggest, using git means that you have to set the uri of the repository containing your configurations and not a local files. If you want to use local files you should configure your server like this:
spring:
profiles:
active: native
cloud:
config:
server:
native:
searchLocations: file:///...

Related

How to access multiple application yml from difference service on configure server(Spring)

I have configured "configure-server" by fetching all configuration from gitlab repository.
Currently, when application(config-server) start it fetch all application properties in git repo.
In case, I have two client application A,B
which has difference application properties like
aplication-a.yml
aplication-b.yml
when application A start, I just only want configure-service fetch only application-a.yml from git repositry.
Here is application configure:
Configure Server
server:
port: 9000
spring:
application:
name: CONFIG-SERVER
cloud:
config:
server:
git:
uri: https://gitlab.com/mama/cloud-configure-server.git
clone-on-start: true
default-label: main
Application A
spring:
cloud:
config:
enabled: true
uri: http://localhost:9000
How to tell configure-service fetch only application-a.yml from git repository?
In case, I don't want to fetch all?
Thank you!!

Adding multiple repositories to Spring cloud config server

I need to add two config repositories to my config server. But, it picks only one config repository. Can anyone please help me to fix this problem.
Config Server bootstrap.yml
server:
port: 8899
spring:
cloud:
config:
server:
git:
uri: https://github.com/pocuser9x/wednest-config-store
search-paths:
- 'wednest-config-store/*service'
repos:
uri: https://github.com/pocuser9x/secure-config-store
In https://github.com/pocuser9x/wednest-config-store I have below files
event-service.yml
event-service-dev.yml
event-service-stg.yml
These files are picking correctly.
In https://github.com/pocuser9x/secure-config-store I have below file
event-service-prod.yml
This file is not picking.
I think what you are looking for is the composite repo feature. It is documented here.
For you, this would be something like:
spring:
profiles:
active: composite
cloud:
config:
server:
composite:
-
type: git
uri: https://github.com/pocuser9x/wednest-config-store
search-paths:
'wednest-config-store/*service'
-
type: git
uri: https://github.com/pocuser9x/secure-config-store
One note is that the documentation shows profile set as above, but I found a need to use "include" instead of "active". Include is additive.
profiles:
include: composite

How can I integrate Spring Cloud with logback?

I have two Spring Boot applications:
cloud-config
It has following file structure:
└───src
└───main
└───environment
└───default
├───application.yml
└───bootstrap.yml
...
application.yml:
server:
port: 8087
spring:
cloud:
config:
server:
git:
uri: ssh://path-to-repository.git
bootstrap.yml:
spring:
application:
name: cloud-config
main-application:
└───src
└───main
└───environment
└───default
├───bootstrap.yml
└───logback.xml
I have application.yml for my main-application in git repository.
Also in git repository I have file with properties: application-default.properties.
I want to move logback.xml to git repository to get it with spring-cloud. How can I do this?
To solve my task I have done following:
add logback.xml to my Spring Cloud repository;
remove logback.xml from main > environment > default directory;
add to bootstrap.yml of main-application module:
logging:
config: http://localhost:8087/main-application/default/master/logback.xml
Documentation: description of logging: config: path: Serving plain text
logging.config=${spring.cloud.config.uri}/guestservices/default/master/logback.xml
works for me.

Spring cloud config local and remote repositories for different profiles

I'm trying to setup my application with multiple repositories - a local file based one for development/testing purpose and a remote git repo for production.
I am using the following yaml for this purpose -
spring:
application:
name: localRepoConfig
cloud:
config:
server:
git:
uri: https://github.com/spring-cloud-samples/config-repo
repos:
development:
pattern:
- '*/development'
- '*/staging'
uri: https://github.com/development/config-repo
native:
searchLocations: classpath:/config
server:
port: 8888
This is not working however, the following works for the local repo -
spring:
application:
name: localRepoConfig
profiles:
active: native
cloud:
config:
server:
native:
searchLocations: classpath:/config
server:
port: 8888
I have not been able to make the two repositories function, after following the Spring documentation and a few posts here.
Would greatly appreciate if someone can point me in the right direction.
I got this working with the following config in bootstrap.yml -
spring:
application:
name: localRepoConfig
profiles:
active: native
cloud:
config:
server:
native:
searchLocations: classpath:/config
server:
port: 8888
---
spring:
profiles: development
cloud:
config:
server:
git:
uri: https://github.com/spring-cloud-samples/config-repo
server:
port: 8989
I am able to switch between the native and development profiles now.
The following guide was quite helpful -
kubecloud.io/guide-spring-cloud-config/
Based on the documentation on Spring Cloud Config it sounds like native and git are mutually exclusive and that you can't use both for a single config server.

Spring cloud config directory structure

I have a working Spring cloud config server who provides configuration from a git repository. All configurations are stored in the root directory in the repository. They are named {name}-{profile}.yml.
I have changed the directory structure to {name}/{profile}.yml
When I curl http://configserver:8888/appname/myprofile the config server I get a json response but the propertySources is empty.
My spring cloud server config
spring:
cloud:
config:
server:
git:
uri: http://git#git.host/scm/cas/application-config.git
You need to add cloud.config.server.git.searchPaths to the configuration server application.yml.
cloud:
config:
server:
git:
searchPaths: <directory>

Resources