[apolloconfig/apollo]Spring Boot Actuator 配置 在启动过程中出现本地配置文件优先级大于Apollo配置文件

2024-06-25 613 views
8

描述bug

SpringBoot应用在启动过程中,在判断Actuator配置是否开启时,优先读取的是本地配置文件配置的值

我是按照集成Springboot的方式去配置的,在bootstrap.properties中配置的: app.id= xxxxx apollo.meta= http://xxxxxxxx apollo.bootstrap.enabled = true apollo.bootstrap.namespaces = application apollo.bootstrap.eagerLoad.enabled=true

复现

通过如下步骤可以复现:

  1. Apollo配置中心配置: management.endpoints.web.exposure.include = httptrace,health management.endpoints.web.base-path = /actuator management.endpoint.health.show-details = always management.health.diskSpace.enabled = true

2.本地配置文件application.yml配置: management.endpoints.web.exposure.include = httptrace,health management.endpoints.web.base-path = /actuator management.endpoint.health.show-details = always management.health.diskSpace.enabled = false

3.启动springboot应用

期望

正常应该以Apollo配置中心的配置为准,开启diskSpace的健康检查,实际上却是以本地配置文件为准,未开启diskSpace的配置检查,也就是未注入diskSpace检查的Bean到容器中

截图 以下是系统启动过程中,判断Spring Actutor是否开启的源码进行debug,此时发生的时机是扫描包目录下的Component Bean时:

org.springframework.boot.actuate.autoconfigure.OnEndpointElementCondition: image Environment对象的值: image 不符合Apollo的设计思路: image

额外的细节和日志
  • 版本: Apollo Client: 1.9.1
    Spring Boot: 2.3.12.RELEASE

  • 平台和操作系统 :Ubuntu 18.04.3 LTS (GNU/Linux 4.15.0-55-generic x86_64)

回答

5

There is a related fix(https://github.com/apolloconfig/apollo-java/pull/3), would you please help to try the 2.1.0-SNAPSHOT version to see if it fixes your issue? You could add the following in your pom.xml and update the apollo client version to 2.1.0-SNAPSHOT.

    <repositories>
        <repository>
            <id>sonatype-nexus-snapshots</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
2

Yeah,很棒的解决了这个Issue,请问什么时候release 2.1.0正式版本?

2

再请教一下,如果client升级到2.1.0版本,服务端也要升级到2.1.0版本吗?