2013-06-26 69 views
0

我試圖從Mule中的.properties文件加載值,並且當文件明顯存在時,我得到了FileNotFound異常。我試過把文件放在項目目錄中,使用相對路徑,但沒有任何作用。從Mule中的.properties文件加載時出現FileNotFound異常

下面是相關的東西從我的騾子流 -

<?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> 

有沒有什麼辦法讓過去的這個問題呢?

回答

2

settings.properties文件在類路徑(直接在src /主/資源/在你的項目),並參照這樣說:

<context:property-placeholder location="settings.properties" />

2

的上下文屬性佔位符的默認外觀到類路徑中。

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

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

這應該有效。

最優選的方法是將屬性文件保留在項目類路徑中。

希望這會有所幫助。

相關問題