访问位于cloudhub上src/main/resources中的自定义属性文件中的mule-app.properties [英] Accessing mule-app.properties in custom properties file located in src/main/resources on cloudhub

查看:116
本文介绍了访问位于cloudhub上src/main/resources中的自定义属性文件中的mule-app.properties的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Mule apikit构建的Mule应用程序. mule-app.properties文件包含以下属性:

I have a mule application built using mule apikit. The mule-app.properties file contains below property:

orig.db.url=jdbc:db2://mmrs001.nmd.net:1004/dudu:user=abc43;password=xxxx;

自定义属性文件src/main/resources/dev.properties包含以下属性:

The custom properties file src/main/resources/dev.properties contains below property:

db.url=${orig.db.url}

并且,m子配置xml文件包含以下property-placeholder:

And, the mule configuration xml file contains below property-placeholder:

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

现在,当我在本地部署它时,一切正常,并且能够运行该流程.但是,与此同时,当我在Cloudhub上进行部署时,它给了我以下例外:

Now, when I deploy it locally everything works fine and I am able to run the flow. But, at the same time when I deploy on Cloudhub it gives me below exception:

Invalid bean definition with name 'get:/total_amount:total_amount-db-config' defined in null: Could not resolve placeholder 'orig.db.url' in string value "jdbc:db2://mmrs001.nmd.net:1004/dudu:user=abc43;password=xxxx;"

我无法理解我在这里想念什么?

I am unable to understand what am I missing here?

推荐答案

mule-app.properties将被添加到系统属性中,而不是类路径属性中.我们无法从添加到classpath的属性文件中引用系统属性.我们需要将这些属性移到类路径以在运行时解决这些问题.

The mule-app.properties will get added to system properties instead of classpath properties. We can't refer to system properties from property files added to classpath. We need to move these properties to classpath to resolve these in runtime.

通过使用以下命令导入mule-app.properties来覆盖此行为的一种方法:

One way to override this behaviour by importing mule-app.properties using:

<context:property-placeholder location="mule-app.properties,dev.properties"/>

它告诉弹簧按各自的顺序加载属性.因此,首先加载了mule-app.properties,然后是dev.properties.

It tells spring to load properties in respective order. So, first mule-app.properties gets loaded and then dev.properties.

但是,将mule-app.properties文件包含在类路径中不是最佳实践.最好的方法是从mule-app.properties中删除dev属性,并将其放入dev.properties中.

But, its not the best practice to include the mule-app.properties file in the classpath. Best way is to remove the dev properties from mule-app.properties and put it inside dev.properties.

这篇关于访问位于cloudhub上src/main/resources中的自定义属性文件中的mule-app.properties的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆