【发布时间】:2020-10-17 11:39:58
【问题描述】:
我在 S3 存储桶中有一堆 spring application.yml 属性文件,用于不同的环境。我想从 S3 存储桶加载属性文件以保证无状态配置。
// Config Object
@Configuration
@ConfigurationProperties(prefix = "yaml")
public class YamlFooProperties {
private String name;
private List<String> aliases;
// standard getter and setters
}
// foo.yml file located in S3 bucket
yaml:
name: foo
aliases:
- abc
- xyz
如何让我的 spring-boot 应用程序加载这些属性并在应用程序启动时使其可用?
我正在使用 spring-boot 版本 2.2.6.RELEASE 和 Java 11。
【问题讨论】:
-
根据baeldung.com/spring-reloading-properties#reloading-from-file 可以使用
–spring.config.location=file://{path to file}.从文件中注入属性可以提供帮助吗?
标签: java spring-boot amazon-s3 spring-boot-test