简体   繁体   English

Spring Cloud Server 未从 BitBucket/Gitlab 导入集中配置

[英]Spring Cloud Server not importing centralized configuration from BitBucket/Gitlab

I'm trying to implement an example for Spring Cloud centralized configuration.我正在尝试为 Spring Cloud 集中配置实现一个示例。 I have my Spring Cloud server which gets the configurations from a git repository and send them to another app.我有我的 Spring Cloud 服务器,它从 git 存储库获取配置并将它们发送到另一个应用程序。 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.如果我使用公共 Github 存储库没有问题,但是当我使用GitlabBitbucket私有存储库时,我无法加载我的新配置。

This is my server application.properties:这是我的服务器 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:我还尝试以这种方式指定 uri:

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).存储库中的项目与从我的公共 Github 存储库导入的项目(有效的)完全相同。

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.另一个奇怪的问题,关于接收到配置的客户端是,如果换上@SpringBootApplication或者把我的@RestController,所以我必须重新启动客户端应用程序,让它获得新的配置,@RefreshScope不起作用。

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 确保用户名/密码正确:

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

Also, the @RefreshScope doesn't poll for updated configurations.此外,@RefreshScope 不会轮询更新的配置。 You need to POST to the /refresh endpoint (which needs to be enabled)您需要 POST 到 /refresh 端点(需要启用)

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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