【问题标题】:FileNotFound exception while loading from a .properties file in Mule从 Mule 中的 .properties 文件加载时出现 FileNotFound 异常
【发布时间】:2018-03-03 21:29:03
【问题描述】:

我正在尝试从 Mule 中的 .properties 文件加载值,但当文件明显存在时,我得到了 FileNotFound 异常。我尝试将文件放在项目目录中,使用相对路径但没有任何效果。

这是我的 Mule 流程中的相关内容 -

<?xml version="1.0" encoding="UTF-8"?>

<mule 
xmlns:context="http://www.springframework.org/schema/context"
xmlns:file="http://www.mulesoft.org/schema/mule/file" 
xmlns="http://www.mulesoft.org/schema/mule/core" 
xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" 
xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc" 
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" 
xmlns:spring="http://www.springframework.org/schema/beans" 
xmlns:core="http://www.mulesoft.org/schema/mule/core" 
version="EE-3.4.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/current/mule-jdbc-ee.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<context:property-placeholder location="C:\path\to\file\settings.properties" />

<oracle data source info />
<connector info />
<flow name="temp" doc:name="Temp" >
<other stuff />
</flow>
</mule>

有什么办法可以解决这个问题吗?

【问题讨论】:

    标签: xml mule mule-studio


    【解决方案1】:

    settings.properties 文件放在你的类路径中(直接在你的项目中的 src/main/resources/ 下)并像这样引用它:

    &lt;context:property-placeholder location="settings.properties" /&gt;

    【讨论】:

      【解决方案2】:

      默认情况下,上下文属性占位符查看类路径。

      使用以下配置在文件存在的物理路径中查找文件。

      <context:property-placeholder location="file:C:/path/to/file/settings.properties" />
      

      这应该可行。

      最首选的方法是将属性文件保存在项目类路径中。

      希望这会有所帮助。

      【讨论】:

        【解决方案3】:

        将属性文件放在 app/main/src 等类路径中。它会工作 有关属性文件的更多信息,请查看以下链接。

        https://docs.mulesoft.com/mule-user-guide/v/3.5/configuring-properties

        【讨论】:

        • 在此处添加一些描述
        猜你喜欢
        • 1970-01-01
        • 2018-07-07
        • 1970-01-01
        • 1970-01-01
        • 2011-02-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多