使用 svn 作为存储库的 spring-cloud-config-server 的奇怪问题 [英] Strange issue with spring-cloud-config-server with svn as repository

查看:52
本文介绍了使用 svn 作为存储库的 spring-cloud-config-server 的奇怪问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 spring-cloud-config-server 和 SVN 作为存储库.当我启动 cloud-config-server 和 client[microservice] 时,配置值被正确获取.

I am using spring-cloud-config-server with SVN as repository. When I start the cloud-config-server and client[microservice], configuration value is picked up properly.

更改配置值和 SVN 提交后,我触发刷新 POST 调用,URL:http://localhost:8080/actuator/refresh [8080 是客户端端口].SVN 中的更新值未刷新.

After changing a configuration value and SVN commit, I am firing refresh POST call, URL: http://localhost:8080/actuator/refresh [8080 is client port]. The updated value in SVN is not getting refreshed.

众所周知,config-server 将 SVN 数据存储在本地.[在我的例子中,文件夹位置 -/tmp/config-repo-5393789580706388886] 这里奇怪的是,SVN 中提交的更改被更新在本地,一旦刷新"REST 调用被触发.但只是应用程序没有接收它.

It is known that config-server stores the SVN data locally.[In my case, folder location - /tmp/config-repo-5393789580706388886] The strange thing here is that, the committed change in SVN is updated locally, once the 'refresh' REST call is triggered. But it is just that application is not picking it up.

Spring Boot 版本 - 2.1.3.
云版本 - 格林威治版.

Spring boot version - 2.1.3.
Cloud version - Greenwich Release.

配置服务器详细信息:

Maven 依赖:

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>

<dependency>
<groupId>org.tmatesoft.svnkit</groupId>
<artifactId>svnkit</artifactId>
</dependency>

application.yml:

application.yml:

spring:
  application:
    name: spring-cloud-config-server
  profiles:
    active: subversion
  cloud:
    config:
      server:
         svn:
           uri: https://svn.*****.com/repos/****/microservices
           username: #####
           password: #####
         default-label: source
server:
  port: 8888

config-client[微服务] 详细信息:Maven 依赖:

config-client[microservice] details: Maven dependency:

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>

application.yml:

application.yml:

spring:
  application:
    name: [client-app-name]
  cloud:
    config:
      uri: http://localhost:8888
management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: ALWAYS
  security:
   enabled: false
server:
  port: 8080

在启动 config-client 微服务时,能够看到它正在通过 config-server 从预期的 SVN 位置获取值.

While starting the config-client microservice, able to see that it is fetching the values from the expected SVN location via config-server.

c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
c.c.c.ConfigServicePropertySourceLocator : Located environment: name=[client-app-name], profiles=[default], label=null, version=10718, state=null
b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource {name='configService', propertySources=[MapPropertySource {name='configClient'}, MapPropertySource {name='https://svn.*****.com/repos/****/microservices/source/[client-app-name].properties'}]}

在调用测试 REST 调用以从配置客户端获取配置值时,我从 SVN 获取值.

While invoking the test REST call to get the configuration value from config client, I am getting the value from SVN.

在文件中进行更改后,[client-app-name].properties 并提交到 SVN.在执行 REST 调用 http://localhost:8080/actuator/refresh 时,得到以下响应,正如预期的那样.

After doing the change in the file , [client-app-name].properties and committing to SVN. While doing the REST call http://localhost:8080/actuator/refresh, getting the following as response, which is as expected.

[]-bash-4.2$ curl -X POST http://localhost:9000/actuator/refresh
["config.client.version","configValue"]-bash-4.2$

同时,按预期从日志中获取以下消息.

At the same time, getting the following message from logs as expected.

c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
c.c.c.ConfigServicePropertySourceLocator : Located environment: name=[client-app-name], profiles=[default], label=null, version=10718, state=null
b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource {name='configService', propertySources=[MapPropertySource {name='configClient'}, MapPropertySource {name='https://svn.*****.com/repos/****/microservices/source/[client-app-name].properties'}]}

对 config-client 的 REST 调用,以获取更新的配置,仅返回先前的配置值.

The REST call to the config-client , to fetch the updated configuration just returning the previous configuration value.

如果我重新启动客户端,它会选择更新的最新配置.此外,本地更新的 SVN 更改[在我的情况下,文件夹位置 -/tmp/config-repo-5393789580706388886]

我真的无法找出我犯的错误.解决此问题的任何输入都将非常有帮助.非常感谢.

I am really not able to find out the mistake I did. Any inputs to resolve this would be very much helpful. Thanks a lot.

推荐答案

您是否为组件设置了 @RefreshScope 注解?

Did you set @RefreshScope annotation to your Component?

例如,TestProperties 是具有 configValue 的 @ConfigurationProperites.

For example, TestProperties is the @ConfigurationProperites that have configValue.

@Bean
public TestComponent(TestProperties properties) {
    return new TestComponent(properties.getConfigValue());
}

如果你像上面的例子一样使用原始的 configValue,你必须注释它.

If you are using raw configValue like above example, you have to annotate it.

@Bean
public TestComponent(TestProperties properties) {
    return new TestComponent(properties);
}

如果您按原样使用属性,它将被刷新.

If you are using properties as it is, it would be refreshed.

这篇关于使用 svn 作为存储库的 spring-cloud-config-server 的奇怪问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆