【问题标题】:Using Mule Expressions in a Spring Configuration在 Spring 配置中使用 Mule 表达式
【发布时间】:2012-01-30 19:33:57
【问题描述】:

我正在设置一个 Mule 应用程序,我想在其中使用 Spring bean 来连接 EHCache 和 JDBC 连接。我不想将配置信息放在我创建的每个 Mule 应用程序中,而是想使用一个位于 $mule_home/conf 的属性文件。

我知道如何使用 Mule 表达式来访问 Mule 主目录 (#[mule:context.homeDir]),但是当我尝试将该表达式放入我的 context.xml 文件中时,我将其链接到我的 mule 应用程序配置中,然后启动服务器,我得到一个

java.io.FileNotFoundException: #[mule:context.homeDir]\conf\jdbc.properties (The system cannot find the path specified)

即使我在 mule 配置中创建了一个单独的属性,${homeDir} 的值为 #[mule:context.homeDir] 它也会给我同样的错误,除了 ${homeDir} 无法解决。

我已经打开日志,可以看到它连接了属性${homeDir},但似乎属性占位符不想解决它。我已经尝试过并使用 PropertyPlaceholderConfigurer 类的原始 bean:

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>file:#[mule:context.homeDir]/conf/jdbc.properties</value>
            <value>file:#[mule:context.homeDir]/conf/standalone-ehcache.conf</value>
            <value>classpath:gateway.properties</value>
        </list>
    </property>
</bean>

【问题讨论】:

    标签: spring mule


    【解决方案1】:

    ${MULE_HOME}/conf 位于 Mule 的类路径中,因此以下内容应该有效:

    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
      <property name="locations">
        <list>
            <value>classpath:jdbc.properties</value>
            <value>classpath:standalone-ehcache.conf</value>
            <value>classpath:gateway.properties</value>
        </list>
      </property>
    </bean>
    

    【讨论】:

    • 这行得通...我找不到任何文档,但你说得对,这行得通。非常感谢。
    猜你喜欢
    • 2015-06-01
    • 1970-01-01
    • 2013-08-03
    • 1970-01-01
    • 1970-01-01
    • 2013-01-13
    • 2018-05-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多