不从配置服务获取属性

Not fetch properties from config service

对配置服务的 GET 请求 http://localhost:8888/dictionary/default return 有效 JSON 具有属性。

字典服务在没有属性的情况下无法启动:

@SpringBootApplication
@EnableEurekaClient
public class DictionaryApplication {

    public static void main(String[] args) {
        SpringApplication.run(DictionaryApplication.class, args);
    }

}

bootstrap.yml

spring:
  application:
    name: dictionary
  profiles:
    active: default
  cloud:
    config:
      uri: localhost:8888/dictionary

build.gradle

ext {
    set('springCloudVersion', "2021.0.2")
}

dependencies {
    implementation 'org.springframework.cloud:spring-cloud-starter-bootstrap'
    implementation 'org.springframework.cloud:spring-cloud-config-client'
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-validation'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
    compileOnly 'org.projectlombok:lombok'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    runtimeOnly 'org.postgresql:postgresql'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

什么是错误?为什么不获取属性?

您不需要将 /dictionary 路径添加到您的 云配置 urilocalhost:8888 就够了。