【问题标题】:Aries blueprint and system properties白羊座蓝图和系统属性
【发布时间】:2014-10-05 19:37:27
【问题描述】:

我想获取系统属性(例如用户名)并将它们作为属性传递给 aries 蓝图中的 bean。传递属性占位符默认值的东西,例如系统属性中的用户名或计算机名:

<cm:property-placeholder id="placeholder" persistent-id="config">
        <cm:default-properties>
            <cm:property name="group.password" value="${username}" />
        </cm:default-properties>
    </cm:property-placeholder>

或将其传递给 bean,如下所示:

<bean id="mapStoreConfig" class="com.acme.mypackage.MyBean">
    <property name="enabledp" value="${username}" />
</bean>

我已经搜索和搜索,但找不到任何解释如何执行此操作。我应该使用 env:username 还是类似的东西?

【问题讨论】:

    标签: apache osgi blueprint aries


    【解决方案1】:

    试试这个:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" 
        xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0">
    
        <ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]" />
    </blueprint>
    

    【讨论】:

    • 感谢 Christian 的帮助,我可以做到。实际上,我什至现在在互联网上找到了它,将“占位符前缀”添加到搜索中。我想出了这个:&lt;!-- Allow the use of system properties --&gt; &lt;ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]" /&gt; 以及使用这行代码允许蓝图访问系统变量的解释。
    猜你喜欢
    • 1970-01-01
    • 2013-05-29
    • 1970-01-01
    • 2015-08-17
    • 2012-03-20
    • 1970-01-01
    • 1970-01-01
    • 2014-06-22
    • 1970-01-01
    相关资源
    最近更新 更多