1
在读取stackoverflow上的answers对之后。我试图执行它的建议方式,但我仍然没有得到我的component
中的字符串列表。将application.yml中的字符串列表加载到组件中
这里是我的application.yml
文件
appName:
db:
host: localhost
username: userX
password: passX
driverClassName: org.postgresql.Driver
shipment:
providers:
supported1:
- one
- two
而且我component
类是
@Component
@ConfigurationProperties(prefix = "appName.shipment.providers")
public class ProviderUtil {
List<String> supported1;
/* This class has other util methods as well */
}
在这里,我期待的是supported1
将有串one
和two
的列表中,但它是空的。有人能帮助这里发生的事情以及如何解决它吗?
是啊,我有整整增加它它在文档中提到的方法。与'可选'值设置为'真正',我用'组件'因为这个响应>> http://stackoverflow.com/questions/26699385/spring-boot-yaml-configuration-for-a-list-of-字符串...这就是说,我已经尝试了'配置'和'组件',但没有运气 –
尝试分享你的代码,看看我们能否以某种方式帮助你。 – bilak
我想出了这个问题。我没有提供getters/setters。我已经公开了这个领域,我认为它会起作用 –