0
我需要玩一个属性文件的键。关键是动态的,所以我需要下面提到的属性文件的bean作为我当前运行的Spring应用程序。如何在Spring-Boot中获取属性文件的bean?
Spring配置文件:
<bean id="multipleWriterLocations" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="ignoreResourceNotFound" value="true" />
<property name="locations">
<list>
<value>classpath:writerLocations.properties</value>
<value>file:config/writerLocations.properties</value>
</list>
</property>
</bean>
Java代码:
Properties prop = appContext.getBean("multipleWriterLocations")
我需要在春季启动相同属性的bean实例。我需要将现有的Spring应用程序转换为Spring-Boot,而无需更改功能。
使用@PropertySource()获取属性文件值的一种方法,但在这种情况下,我需要密钥名称。但在我的情况下,键名是未知的,我需要从属性bean中获取keySet。
感谢ck1的帮助。它工作完美。 – Saurabh