Store your agt-commission.properties
file in src/main/resources
instead of src/main/app
.
By default files under app
doesn't get copied to classes
which is causing FileNotFoundException
سؤال
I have a Mule flow that I wish to configure via a Spring .properties file. I have read the Mule documentation on how to do this and I'm pretty sure I have it correct, but I get:
Could not load properties; nested exception is java.io.FileNotFoundException:
class path resource [agt-commission.properties] cannot be opened because
it does not exist
My Mule flow XML file begins with:
<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>
My properties file is located in the src/main/app
folder as specified by the documentation and I have copied and pasted the file name, so I know that is the same.
I am running the project from Mule Studio (3.5.0) as a Mule application.
Why can't Spring find the properties file?
المحلول
Store your agt-commission.properties
file in src/main/resources
instead of src/main/app
.
By default files under app
doesn't get copied to classes
which is causing FileNotFoundException
نصائح أخرى
For Property placeholder files the better location is src/main/resources.
As properties file to be provided in the app folder, is the mule-deploy properties which has the details of the application deployment.
Move your resource file to src/main/resources and it should work with your config file.
Note: This will work when the build in the POM has got the src/main/resources declared as resource
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
</resource>
</resources>
Hope this helps.