【发布时间】:2018-08-17 11:44:51
【问题描述】:
我的 springboot 应用程序 (1.5.4.RELEASE) 中的 application.properties 中有以下内容
my.prefix.one.id=id01
my.prefix.one.name=one
my.prefix.two.id=id02
my.prefix.two.name=two
还有一个像下面这样的类
public class MyClass{
private String id;
private String name;
//getters and setters
}
如果我使用 @ConfigurationProperties(prefix="my.prefix.one") 那么我会得到一个带有 id 字段“id01”的 MyClass bean。
有没有办法指示springboot扫描扫描所有带有前缀“my.prefix”的属性并创建多个bean。在这种情况下,两个 bean - id 字段为“id01”的 bean 和 id 字段为“id02”的 bean?
【问题讨论】:
标签: java spring spring-boot