美文网首页
PropertiesFactoryBean PropertyPl

PropertiesFactoryBean PropertyPl

作者: baby_honour | 来源:发表于2019-07-16 16:24 被阅读0次

    正如 stackoverflow 上说的,PropertiesFactoryBean 是PropertiesLoaderSupport 直接的实现类, 专门用来管理properties文件的工厂bean,默认是单例的,

    而 PropertyPlaceholderConfigurer 是 解决 properties 文件占位符问题的,也实现了 PropertiesLoaderSupport 类。

    在java 代码里,一般是使用@Value注解来引用 properties 文件的属性。

    使用 PropertyPlaceholderConfigurer 时,
    @Value表达式的用法是 @Value(value="${properties key}")

    使用 PropertiesFactoryBean 时,我们还可以用@Value 读取 properties对象的值,
    @Value 用法 是 @Value(value="#{configProperties['properties key']}")

    相关文章

      网友评论

          本文标题:PropertiesFactoryBean PropertyPl

          本文链接:https://www.haomeiwen.com/subject/sdutlctx.html