【问题标题】:camel property file not found in class path在类路径中找不到骆驼属性文件
【发布时间】:2014-10-29 08:06:03
【问题描述】:

我正在尝试从类路径中读取属性文件。

我有项目名称 - PROG,在它下面有一个名为 resources 的文件夹,其中有一个属性文件:myProp

在骆驼上下文 xml 中,我的代码是:

<propertyPlaceholder id="properties" location="classpath:PROG.resources.myProp" />

我也试过了:

<propertyPlaceholder id="properties" location="classpath:resources.myProp" />

但我得到骆驼错误:

java.io.FileNotFoundException: Properties file PROG.resources.myProp not found in classpath

有什么想法吗?

【问题讨论】:

    标签: apache-camel properties-file


    【解决方案1】:

    我正在使用此 XML 代码来配置属性占位符:

    <propertyPlaceholder id="properties" location="classpath:/resources/myProp" />
    

    这是来自https://camel.apache.org/using-propertyplaceholder.html的官方示例:

    <bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent">
        <property name="location" value="classpath:com/mycompany/myprop.properties"/>
    </bean>
    

    尝试使用真实路径,而不是“.”来自ResourceBundle 的符号。

    【讨论】:

    • 这并没有提供问题的答案。要批评或要求作者澄清,请在其帖子下方发表评论。
    • 嗯,这就是我在代码中的做法以及camel.apache.org/using-propertyplaceholder.html 在“在 Spring XML 中配置”一节中如何描述它。
    • 如果您希望他们被接受,您需要给出更完整的答案。试试这个不太可能让你回答尝试或接受。即使它是正确的。
    • 用更多细节和 Camel 文档中的示例修改了答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-11-01
    • 2014-12-14
    • 1970-01-01
    • 2021-11-04
    • 2012-09-13
    • 2014-07-12
    • 1970-01-01
    相关资源
    最近更新 更多