2013-10-14 29 views
3

我有一個騾流,我希望通過Spring.properties文件進行配置。我已閱讀如何做到這一點的騾子的文檔和我敢肯定我有它正確的,但我得到:騾找不到使用Spring的屬性文件

Could not load properties; nested exception is java.io.FileNotFoundException: 
class path resource [agt-commission.properties] cannot be opened because 
it does not exist 

我的騾子流的XML文件開始:

<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" 
xmlns="http://www.mulesoft.org/schema/mule/core" 
xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" 
xmlns:http="http://www.mulesoft.org/schema/mule/http" 
xmlns:file="http://www.mulesoft.org/schema/mule/file" 
xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc" 
xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" 
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" 
xmlns:context="http://www.springframework.org/schema/context" 
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/http 
http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd 
http://www.mulesoft.org/schema/mule/file 
http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd 
http://www.mulesoft.org/schema/mule/ee/jdbc 
http://www.mulesoft.org/schema/mule/ee/jdbc/current/mule-jdbc-ee.xsd 
http://www.mulesoft.org/schema/mule/ee/data-mapper 
http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.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/ee/tracking 
http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd 
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.0.xsd"> 

<spring:beans> 
    <context:property-placeholder location="classpath:agt-commission.properties"/> 
</spring:beans> 

我的屬性文件位於文檔中指定的src/main/app文件夾中,並且我複製並粘貼了文件名,所以我知道這是相同的。

Project structure

我正在從騾工作室(3.5.0)作爲騾子應用程序的項目。

爲什麼Spring不能找到屬性文件?

+2

你能看到你的proerties文件在你的classes文件夾裏嗎? –

+0

不知道該怎麼做。 classes文件夾在哪裏? –

+0

@DebojitSaikia我已經檢查過生成所有'.class'文件的'/ bin /'文件夾,並且'.properties'文件不會被複制到那裏。不知道如何強迫它在那裏。 –

回答

3

將您的agt-commission.properties文件存儲在src/main/resources而不是src/main/app

默認文件app下不會被複制到classes這是造成FileNotFoundException

0

物業佔位符文件的更好位置的src/main /資源。

作爲應用程序文件夾中提供的屬性文件,是具有應用程序部署細節的mule-deploy屬性。

將您的資源文件移動到src/main/resources,它應該與您的配置文件一起工作。

注:當在POM構建已得到聲明爲資源

<resources> 
     <resource> 
      <filtering>true</filtering> 
      <directory>src/main/resources</directory> 
     </resource> 
</resources> 

希望這有助於在src /主/資源這將工作。

相關問題