简体   繁体   中英

Spring Cloud Server not importing centralized configuration from BitBucket/Gitlab

I'm trying to implement an example for Spring Cloud centralized configuration. I have my Spring Cloud server which gets the configurations from a git repository and send them to another app. No problems if I use a public Github repository , but when I use a Gitlab or Bitbucket private repositories, I cannot get my new configurations loaded.

This is my server application.properties:

server.port=8888
#gitlab
spring.cloud.config.server.git.uri=https://gitlab.com/myusername/reponame
spring.cloud.config.server.git.username=myusername
spring.cloud.config.server.git.password=mypassword

I've also tried to specify the uri this way:

spring.cloud.config.server.git.uri=https://gitlab.com/myusername/reponame.git

with no results. The project in the repo is exacly the same of the one imported from my public Github repository (the one which works).

Another strange issue, regarding the Client which receives the configuration is that @RefreshScope doesn't work if put on @SpringBootApplication or if put on my @RestController , so I have to restart the Client application to let it get the new configurations.

That's the correct config (double checked my own) so make sure that the username/password are correct by doing a git clone passing in the credentials:

git clone https://myusername:mypassword@gitlab.com/myusername/reponame

Also, the @RefreshScope doesn't poll for updated configurations. You need to POST to the /refresh endpoint (which needs to be enabled)

curl -X POST http://localhost:8080/refresh

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM