简体   繁体   English

propertiesfactorybean vs propertyplaceholderconfigurer spring?

[英]propertiesfactorybean vs propertyplaceholderconfigurer spring?

spring has two ways to load property files using either propertiesfactorybean or propertyplaceholderconfigurer . spring有两种方法可以使用propertiesfactorybeanpropertyplaceholderconfigurer加载属性文件。

Could u please explain the difference between them and when to use what? 你可以解释一下它们之间的区别以及何时使用它们?

Thanks! 谢谢!

PropertiesFactoryBean is a FactoryBean implementation which reads a properties file and exposes that as an Properties object in the applicationcontext. PropertiesFactoryBean是一个FactoryBean实现,它读取属性文件并将其作为applicationcontext中的Properties对象公开。

PropertyPlaceHolderConfigurer is a BeanFactoryPostProcessor implementation that reads a property file and uses that property file to replace placeholder variables (${somename}) with actual values. PropertyPlaceHolderConfigurer是一个BeanFactoryPostProcessor实现,它读取属性文件并使用该属性文件将占位符变量($ {somename})替换为实际值。 The read properties aren't available as a Properties object. 读取属性不可用作Properties对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM