DEV Community

Cover image for Spring Cloud Config Server: Step by Step

Spring Cloud Config Server: Step by Step

Mark Dsouza on March 08, 2021

Spring Cloud Config Server is used to provide server-side and client-side support for externalized configuration in a distributed system. So when y...
Collapse
 
hendisantika profile image
Hendi Santika

Now I have errors again. As follow:
It is said:

gitlab.com/microservice-samples/mi... 422 Unprocessable Entity

2021-05-09 10:08:11.007 WARN 28080 --- [nio-8888-exec-1] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [org.springframework.cloud.config.server.environment.NoSuchRepositoryException: Cannot clone or checkout repository: gitlab.com/microservice-samples/mi...]

But, When I change config from spring.cloud.config.server.git.uri=gitlab.com/microservice-samples/mi... to spring.cloud.config.server.git.uri=file://${user.home}/Desktop/tes/configuration

it works.

Then If I change properties file to yml it error again.

Any suggestion?

Thanks

Collapse
 
markbdsouza profile image
Mark Dsouza

Hey Hendi, Can you try adding a .git to the end of your uri property?

Collapse
 
hendisantika profile image
Hendi Santika

If I am using git it show error. I will show you the link.
This is my repository to implement micro service with Spring Cloud.

Here's the link --> gitlab.com/microservice-samples/mi.... You can try it on your local.

Thanks

Thread Thread
 
hendisantika profile image
Hendi Santika

I will add you to my gitlab group so that You can clone.
May I know your gitlab account?

Thanks

Thread Thread
 
markbdsouza profile image
Mark Dsouza

Thanks tried setting it up on my local and Your yml files seem to be causing the issue. Im not sure how you got it working on your local.
Below would be my suggestion to resolve this
1) Keep either the .properties or .yml file. Don't keep both
2) Use yamllint.com/ to check your yml file. The way you have tried to define your profiles wont work here. Try just 1 default profiles to start off and get it running
3) Initially point it to your local copy of your git repo only having bank-account-service.yml . Access localhost:8888/bank-account-service/default . Only if you see the results here move ahead.
4) Once everything is 100% alright on local, Push your git repo to remote and change the url.
5) To implement profiles the file name needs to change.. in your case bank-account-service-dev.yml
Let me know you need more help :)

Thread Thread
 
hendisantika profile image
Hendi Santika

Hi Mark,

  1. I was trying to use yml file only but it fails. Then I try to use properties file its working fine.
  2. I was check using yamllint.com it is said valid.
  3. I don't know it's not coming the result.
  4. Still error on my local. I already pushed new file.
  5. Previously I tried like that but still error. Now I am rolling back to use bank-account-service-dev.yml & bank-account-service-uat.yml but still error.

Cannot pull from remote gitlab.com/microservice-samples/mi..., the working tree is not clean.

Thread Thread
 
markbdsouza profile image
Mark Dsouza

Hmm any changes to your git repo containing these files, make sure you do a git add and git commit and then restart your cloud config server for it to reflect properly
Also one other thing with the yml file is you don't need the
spring:
config:
activate:
on-profile: dev
if you follow the naming convention.
All you need to do is set the profile for the microservice of the bank-account-service when you run it.

Thread Thread
 
hendisantika profile image
Hendi Santika

It's working now. I am using Spring Cloud Native with File Backend.
Git Backend is to much error for me.

Thank for your support.

Thread Thread
 
markbdsouza profile image
Mark Dsouza

Awesome !

Collapse
 
anuradha151 profile image
Anuradha Ranasinghe

This works for gitlab uri. Why doesn't need this for github uri.

Thread Thread
 
markbdsouza profile image
Mark Dsouza

Sorry anuradha. I didn't get your question.
Are you facing any issues with the tutorial?

Collapse
 
braians profile image
Braian Silva

I forgot to put dependency "Config Client" in my service but now work very well, great article. Thanks

Collapse
 
maxmengtor profile image
maxmengtor

this is the best for scc server setup