Spring Cloud 配置服务器 - 用于刷新密钥的空数组

问题描述 投票:0回答:2
java spring spring-boot maven spring-cloud-config
2个回答
0
投票

在您的

application.yml
中,您已定义
spring.cloud.config.server.git.search-paths
配置键。然而,从 spring 官方文档中查看this doc,关键似乎应该是
searchPaths
(snakeCase,没有破折号)。 因此,我认为你的
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}'

0
投票

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

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

解决了问题。

© www.soinside.com 2019 - 2024. All rights reserved.