我在.properties文件中列出了属性列表。
现在,我正在使用PropertyPlaceholderConfigurer
管理那些属性文件。
我想从一种方法访问属性值。
有人可以建议如何实现吗?
例
connection.properties
dev.url = "http://localhost:8080/"
uat.url = "http://xyz.com"
现在我通过指定connection.properties配置了`PropertyPlaceholderConfigurer bean。
我有一种根据部署模式读取url的方法
所以基于部署模式,我想使用属性文件更改url。
请让我知道这是否正确。
如果您有任何建议,请给。
最佳答案
PropertyPlaceholderConfigurer
does not expose其属性。但是,您可以使用例如轻松轻松地重新读取属性文件。 PropertiesLoadUtils
:
PropertiesLoaderUtils.loadProperties(
new ClassPathResource("/connection.properties"));