【问题标题】:Mule not finding properties file using SpringMule找不到使用Spring的属性文件
【发布时间】:2013-10-22 00:25:30
【问题描述】:

我有一个希望通过 Spring .properties 文件配置的 Mule 流程。我已经阅读了有关如何执行此操作的 Mule 文档,并且我很确定我的理解是正确的,但我明白了:

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

我的 Mule 流 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 文件夹中,我已经复制并粘贴了文件名,所以我知道这是相同的。

我正在将 Mule Studio (3.5.0) 中的项目作为 Mule 应用程序运行。

为什么Spring找不到属性文件?

【问题讨论】:

  • 你能看到你的类文件夹中的属性文件吗?
  • 不知道该怎么做。类文件夹在哪里?
  • @DebojitSaikia 我检查了生成所有.class 文件的/bin/ 文件夹,并且.properties 文件没有复制到那里。不知道如何强制它在那里。
  • 清理并构建您的项目。如果在那之后它仍然没有出现,请尝试在那里手动复制.proerties 文件

标签: java spring mule properties-file


【解决方案1】:

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

默认情况下app 下的文件不会被复制到classes,这会导致FileNotFoundException

【讨论】:

    【解决方案2】:

    对于属性占位符文件,更好的位置是 src/main/resources。

    作为 app 文件夹中提供的属性文件,是 mule-deploy 属性,其中包含应用程序部署的详细信息。

    将您的资源文件移动到 src/main/resources,它应该可以与您的配置文件一起使用。

    注意:当 POM 中的构建将 src/main/resources 声明为资源时,这将起作用

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

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-10
      • 2014-07-30
      • 2012-08-27
      • 2016-09-02
      • 1970-01-01
      • 2013-11-15
      • 1970-01-01
      • 2016-06-01
      相关资源
      最近更新 更多