【问题标题】:Access properties outside spring context访问 spring 上下文之外的属性
【发布时间】:2014-03-04 13:24:45
【问题描述】:

我在我的 spring 上下文中使用<context:property-placeholder> 配置了一些属性。效果很好。

从 spring 上下文(我有一个对 spring ApplicationContext 对象的引用)之外访问这样加载的命名属性的最佳方法是什么。

【问题讨论】:

标签: spring properties


【解决方案1】:

我最终实现并配置了一个 spring Bean,它的属性值注入了 @Value 注释,然后从上下文中检索这个 bean。

不是 100% 优雅,但它确实有效。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-06-04
    • 2010-10-20
    • 2014-05-31
    • 1970-01-01
    • 2017-03-29
    • 1970-01-01
    • 2012-01-06
    • 2023-03-14
    相关资源
    最近更新 更多