【问题标题】:How cloud spring boot uses properties in yml fileCloud Spring Boot 如何使用 yml 文件中的属性
【发布时间】:2021-05-23 03:16:42
【问题描述】:

当使用 Spring Cloud AWS 进行 repo 时,我注意到 application.yml 包含

spring:
  profiles: aws
  cloud:
    config:
      enabled: false
aws:
  paramstore:
    prefix: /micro
    name: microapp
    profileSeparator: #
    enabled: true

但我找不到这些属性的使用位置。通常,yml 属性是通过 @Value 或 @ConfigurationProperties 导入的,但是这里的 repo 中没有为它们使用这样的注释。

pom.xml 文件有 spring-cloud-starter-awsspring-cloud-starter-aws-parameter-store-config 依赖项,我猜这使用了属性。

每当我添加自定义属性(例如 aws.smb.enable)时,pom.xml 都会抱怨“未知属性”。

我实际上并不知道 yaml 文件中的属性如何与 Spring Cloud AWS 一起使用。

【问题讨论】:

    标签: java spring-boot yaml spring-cloud-aws


    【解决方案1】:

    但我找不到这些属性的使用位置。通常,yml 属性是通过 @Value 或 @ConfigurationProperties 导入的,但是这里的 repo 中没有为它们使用这样的注释。

    你在看哪个回购? aws 属性在 Spring Cloud AWS 项目中读取。例如,aws.paramstore 属性在org.springframework.cloud.aws.paramstore.AwsParamStoreProperties using @ConfigurationProperties 中读取。

    所有awscloud.aws 属性都记录在Spring Cloud AWS docs 中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-06-04
      • 2020-02-14
      • 1970-01-01
      • 2014-10-03
      • 2017-09-07
      • 2017-01-03
      • 2016-07-17
      相关资源
      最近更新 更多