[英]Listing the resolved properties in Spring
I have multiple property file sources in my spring xml files, they have different order values and some are optional. 我的spring xml文件中有多个属性文件源,它们有不同的顺序值,有些是可选的。
In other words, I can override the default properties set in application.properties with properties in .properties and override those values in turn by a property file whose location is looked up by jndi. 换句话说,我可以使用.properties中的属性覆盖application.properties中设置的默认属性,并依次通过jndi查找其位置的属性文件覆盖这些值。
What I would like to have however is some way for spring to give my a list of the resolved values of all the properties. 然而,我希望有一些方法让spring给出我所有属性的已解析值列表。 Anyone know how I can do this?
谁知道我怎么做到这一点?
It's easy for me to get the value of a particular property but what I actually need is a list of all the resolved properties. 我很容易获得特定属性的值,但实际需要的是所有已解析属性的列表。
I have two suggestions: 我有两个建议:
PropertyPlaceholderConfigurer
with method processProperties
to populate all the resolved properties. processProperties
覆盖类PropertyPlaceholderConfigurer
以填充所有已解析的属性。 An example is listed here . PropertyPlaceholderConfigurer
implements Spring's Ordered
interface, you can have multiple property place holders; PropertyPlaceholderConfigurer
实现了Spring的Ordered
接口,因此您可以拥有多个属性占位符; then, assign them the order
in the order that should be in your application. order
应用程序中应该的order
为他们分配order
。 Finally, having been already extended the class, you will have access to all resolved properties in the order that should be loaded.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.