स्प्रिंग क्लाउड कॉन्फ़िगरेशन सर्वर - ताज़ा कुंजियों के लिए खाली सरणी

Nov 23 2020

मैं इस के रूप में एक स्प्रिंग बादल config सर्वर है रेपो और इस में एक ग्राहक रेपो निम्नलिखित मेरी पोम फ़ाइल है

<?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>

config सर्वर के application.yml

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}'

यह सर्वर जिस कॉन्फ़िगरेशन रेपो में काम करता है, उसमें निम्न संरचना होती है

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

मेरे पास कॉन्फ़िगर रेपो के लिए एक webhook कॉन्फ़िगर किया गया है। मेरे पास स्थानीय स्तर पर चलने वाली खरगोश की छवि भी है।

जब मैं अपने परिवर्तन को रेपो रेमो पर धकेलता हूं तो मुझे ये लाइन कंसोल पर मिलती है

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 []

रिफ्रेश्ड कीज़ की सरणी खाली है मैंने स्प्रिंग बूट / क्लाउड के पुराने संस्करण में बदलने की कोशिश की, साथ ही एक नया संस्करण भी बनाया, लेकिन मैंने काम नहीं किया।

मैंने अपने मामले के समान प्रश्न देखे हैं, लेकिन उनमें से किसी का भी कोई जवाब नहीं था।

जवाब

jalsh Nov 24 2020 at 06:47

अपने में application.ymlआपने spring.cloud.config.server.git.search-pathsविन्यास कुंजी को परिभाषित किया है। हालाँकि, इस डॉक को वसंत आधिकारिक दस्तावेज़ीकरण से देखते हुए, लगता है कि यह होना चाहिए था searchPaths(स्नेककेस, नो डैश)। इसलिए, मुझे लगता है कि आपका application.ymlइस तरह दिखना चाहिए:

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
          searchPaths: '{application}'
Ali.Wassouf Nov 24 2020 at 09:39

समस्या क्लाइंट में थी, यह स्प्रिंग क्लाउड कॉन्फिगरेशन के साथ-साथ स्प्रिंग क्‍लाउड के लिए निर्भरता प्रबंधन को क्‍लाइंट कोड में इस निर्भरता को जोड़ने से गायब है

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

और इस निर्भरता प्रबंधन को भी जोड़ रहा है

<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>

मुद्दे को हल किया।