Spring Cloud Config Server - 用于刷新密钥的空数组 [英] Spring Cloud Config Server - empty array for refreshed keys

查看:73
本文介绍了Spring Cloud Config Server - 用于刷新密钥的空数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 spring cloud 配置服务器,就像这个 repo以及这个 repo 中的客户端以下是我的POM文件

<project xmlns="http://maven.apache.org/POM/4.0.0";xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation=http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><父母><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.1.8.RELEASE</version><relativePath/><!-- 从存储库中查找父级 --></父母><groupId>com.ali.wassouf.spring.cloud.client</groupId><artifactId>cloud-config-app</artifactId><version>0.0.1-SNAPSHOT</version><name>cloud-config-app</name><description>Spring Boot 的演示项目</description><属性><java.version>1.8</java.version><spring-cloud.version>Greenwich.RELEASE</spring-cloud.version></属性><依赖项><依赖><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-config-server</artifactId></依赖><依赖><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></依赖><依赖><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-stream-rabbit</artifactId></依赖><依赖><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-config-monitor</artifactId></依赖><依赖><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><范围>测试</范围></依赖></依赖项><依赖管理><依赖项><依赖><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>${spring-cloud.version}</version><type>pom</type><范围>导入</范围></依赖></依赖项></dependencyManagement><构建><插件><插件><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></插件></plugins></build></项目>

配置服务器的application.yml

服务器:端口:8081春天:应用:名称:云配置服务器云:配置:服务器:监视器:github:启用:真吉蒂:启用:真吉特:密码:${PASSWORD}用户名:${USERNAME}uri:https://github.com/Ali-Wassouf/springcloudconfigrepo搜索路径:'{application}'

此服务器服务的配置仓库具有以下结构

<预><代码>.+-- 服务A|+-- application-dev.properties|+-- application-prod.properties+-- 服务B|+-- application-dev.properties|+-- application-prod.properties

我为配置存储库配置了一个 webhook.我还有一个在本地运行的 rabbitMQ 镜像.

当我将更改推送到配置存储库时,我会在控制台上看到这些行

o.s.c.c.monitor.PropertyPathEndpoint : Refresh for: *:prods.c.a.AnnotationConfigApplicationContext:刷新 org.springframework.context.annotation.AnnotationConfigApplicationContext@2c943d8f:启动日期 [Mon Nov 23 18:55:19 CET 2020];上下文层次结构的根oscore.annotation.AnnotationUtils:无法内省 [class org.springframework.cloud.config.client.ConfigServiceBootstrapConfiguration$RetryConfiguration] 上的注释:java.lang.IllegalStateException:无法获取公共抽象 java.lang.Class[ 的注释属性值] org.springframework.boot.autoconfigure.condition.ConditionalOnClass.value()trationDelegate$BeanPostProcessorChecker :类型为 [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$aacb9e64] 的 Bean 'configurationPropertiesRebinderAutoConfiguration' 不符合被所有 BeanPostProcessor 处理的条件(例如:不符合自动代理的条件)o.s.boot.SpringApplication :没有设置活动配置文件,回退到默认配置文件:默认s.c.a.AnnotationConfigApplicationContext:刷新 org.springframework.context.annotation.AnnotationConfigApplicationContext@7d2d9a8f:启动日期 [Mon Nov 23 18:55:20 CET 2020];父级:org.springframework.context.annotation.AnnotationConfigApplicationContext@2c943d8fo.s.boot.SpringApplication :在 1.515 秒内启动应用程序(JVM 运行 31.102)s.c.a.AnnotationConfigApplicationContext : 关闭 org.springframework.context.annotation.AnnotationConfigApplicationContext@7d2d9a8f: 启动日期 [Mon Nov 23 18:55:20 CET 2020];父级:org.springframework.context.annotation.AnnotationConfigApplicationContext@2c943d8fs.c.a.AnnotationConfigApplicationContext : 关闭 org.springframework.context.annotation.AnnotationConfigApplicationContext@2c943d8f: 启动日期 [Mon Nov 23 18:55:19 CET 2020];上下文层次结构的根o.s.cloud.bus.event.RefreshListener : 收到远程刷新请求.按键刷新 []

刷新键数组为空我尝试更改为旧版本的 Spring Boot/Cloud,以及更新的版本,但这没有用.

我看到过与我的案例类似的问题,但没有一个有任何答案.

解决方案

问题出在客户端,缺少 spring cloud 配置以及 spring cloud 的依赖管理将此依赖项添加到客户端代码

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

并添加此依赖项管理

<依赖项><依赖><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>${spring-cloud.version}</version><type>pom</type><范围>导入</范围></依赖></依赖项></dependencyManagement>

解决了问题.

I have a spring cloud config server as in this repo And a client in this repo following is my POM file

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.8.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.ali.wassouf.spring.cloud.client</groupId>
    <artifactId>cloud-config-app</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>cloud-config-app</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
        <spring-cloud.version>Greenwich.RELEASE</spring-cloud.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-server</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-monitor</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

application.yml of the config server

server:
  port: 8081
spring:
  application:
    name: cloud-config-server
  cloud:
    config:
      server:
        monitor:
          github:
            enabled: true
          gitee:
            enabled: true
        git:
          password: ${PASSWORD}
          username: ${USERNAME}
          uri: https://github.com/Ali-Wassouf/springcloudconfigrepo
          search-paths: '{application}'

The config repo that this server serves has the following structure

.
+-- serviceA
|   +-- application-dev.properties
|   +-- application-prod.properties
+-- serviceB
|   +-- application-dev.properties
|   +-- application-prod.properties

I have a webhook configured for the config repo. I also have a rabbitMQ image running locally.

When I push my changes to the config repo I get these line on the console

o.s.c.c.monitor.PropertyPathEndpoint     : Refresh for: *:prod
s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@2c943d8f: startup date [Mon Nov 23 18:55:19 CET 2020]; root of context hierarchy
o.s.core.annotation.AnnotationUtils      : Failed to introspect annotations on [class org.springframework.cloud.config.client.ConfigServiceBootstrapConfiguration$RetryConfiguration]: java.lang.IllegalStateException: Could not obtain annotation attribute value for public abstract java.lang.Class[] org.springframework.boot.autoconfigure.condition.ConditionalOnClass.value()
trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$aacb9e64] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
o.s.boot.SpringApplication               : No active profile set, falling back to default profiles: default
s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@7d2d9a8f: startup date [Mon Nov 23 18:55:20 CET 2020]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@2c943d8f
o.s.boot.SpringApplication               : Started application in 1.515 seconds (JVM running for 31.102)
s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@7d2d9a8f: startup date [Mon Nov 23 18:55:20 CET 2020]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@2c943d8f
s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@2c943d8f: startup date [Mon Nov 23 18:55:19 CET 2020]; root of context hierarchy
o.s.cloud.bus.event.RefreshListener      : Received remote refresh request. Keys refreshed []

The array of Refreshed keys is empty I tried changing to an older version of Spring Boot/Cloud, as well as a newer version, but this didn't work.

I have seen questions similar to my case but non of them had any answers.

解决方案

The problem was in the client, it's missing spring cloud config as well as the dependency management for spring cloud adding this dependency to the client code

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

and adding this dependency management as well

<dependencyManagement>
       <dependencies>
           <dependency>
               <groupId>org.springframework.cloud</groupId>
               <artifactId>spring-cloud-dependencies</artifactId>
               <version>${spring-cloud.version}</version>
               <type>pom</type>
               <scope>import</scope>
           </dependency>
       </dependencies>
</dependencyManagement>

Solved the issue.

这篇关于Spring Cloud Config Server - 用于刷新密钥的空数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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