如何在 spring 引导中直接将 application.property 值读入另一个配置 xml 文件

How to directly read application.property value into another configuration xml file in spring boot

我已经在 applicaiton.properties 文件中指定了一些网络服务端点,如下所示 application.properties

config.middleware.soap.service.endpoint.sample=http://xxx.xxx/sample/

现在我想将这些值直接用于另一个配置文件,在我的例子中是 root-context.xml 文件,用于使用 jax-ws 客户端创建 soap class。但是 属性 永远不会被 spring 引导理解,如果我从 applicaiton.properties 值引用它的话。为什么不?如果我直接提供它工作的端点。将 application.properties 文件值用于另一个配置文件的最简单方法是什么? root-context.xml

<jaxws:client id="sampleClient" serviceClass="com.sample.wsdl.sample"
        address="${config.middleware.soap.service.endpoint.sample}">

        ...
    </jaxws:client>

在我的例子中,root-context 和 application.properties 文件都位于 src/main/resources 文件夹中。所以我假设当应用程序引导时,这两个文件都加载到 classpath 上.

当我按照下面提到的方式使用它时,它终于起作用了

<jaxws:client id="acctInqClient" serviceClass="com.ge.india.capital.wsdl.spine.AcctInq"
        address="#{environment['config.middleware.soap.service.endpoint.sample']}">

假设,我在 applicaiton.properties 文件中以 config.middleware.soap.service.endpoint.sample 的名称声明了一个 属性。

但我想知道为什么只有 ${config.middleware.soap.service.endpoint.sample} 不起作用。谢谢。