我有一个关于骡子的上下文属性占位符的一个问题,我有两个文件设置是这样的:骡子ESB:上下文属性占位符
<context:property-placeholder location="classpath:mule-app-1.properties, file:///etc/mule/conf/mule-app-2.properties" />
首先,这是一个有效的配置,其次该文件将优先于其他? app1或app2文件?
-S
我有一个关于骡子的上下文属性占位符的一个问题,我有两个文件设置是这样的:骡子ESB:上下文属性占位符
<context:property-placeholder location="classpath:mule-app-1.properties, file:///etc/mule/conf/mule-app-2.properties" />
首先,这是一个有效的配置,其次该文件将优先于其他? app1或app2文件?
-S
每个将依次加载,覆盖第一个属性的重复属性。所以在你的情况下,在mule-app-2.properties中定义的属性将优先。
接近this article的末尾我描述了使用此方法来提供环境特定的配置属性。
是的,您可以通过Mule上下文属性占位符加载多个文件。正确的方式做它是将性质src/main/resources
文件,此文件夹的类路径,然后指定是这样的:
<context:property-placeholder location="mule-app-1.properties, mule-app-2.properties" />
我不知道为什么你想在他们
定义重复属性编辑:
要指定加载多个文件的顺序,使用order
属性:
<context:property-placeholder location="mule-app-1.properties" order="1"/>
<context:property-placeholder location="mule-app-2.properties" order="2"/>
我也遇到过相同的情况。下面是我的实践经验成果:
如果两个文件存在,无论是内部的项目或服务器,两者将在项目/应用程序启动时加载。如果文件不可用,它将抛出异常(java.io.FileNotFoundException:系统找不到指定的文件)运行应用程序时。
使用多个属性文件并了解优先级是非常有趣的。在这种情况下,两个属性文件都将被加载,因此在这两个文件中定义的属性将在运行时加载。但是,如果在两个文件中定义了相同的属性,则mule总是优先考虑最后声明的文件,并且附加属性如订单尚未定义。
对于实施例,如果有一个属性“db.dbname = test_university”内部
“mule-app-1.properties”和“db.dbname =大学”内部“mule-声明app-2.properties“ then $ {db。DBNAME}配置XML中会加载“大学”
你的配置应该是如下:
<context:property-placeholder location="mule-app.properties, file:C://Users//schiraboina//Desktop//123.txt"/>
在您尝试通过使用读取值以上的情况下'$ {key_name}',优先顺序为 1. mule-app.properties 2.从外部位置读取文件
有关此问题的更多信息。数据将被读取,给予CLASSPATH中数据的首选,然后读取文件中的数据!
Spring将依次加载来自每个资源的属性,当它多次找到它们时覆盖属性。这使您可以为属性提供默认值,并在每个环境中对其进行自定义。
对于如:
<context:property-placeholder
location="classpath:myapp-config.properties,classpath:myapp-config-${MULE_ENV}.properties,file:/opt/mule/conf/${MULE_ENV}/myapp-config.properties"
ignore-resource-not-found="true"
ignore-unresolvable="true" />
这非常类似于刚才你所提到以上,并回答你的问题:
请参考以下链接了解详情: http://confluex.com/blog/integration-software-is-software/
By Tim Hennekey 你可以用这个例子MULE同春:
<spring:bean id="property-placeholderInstance" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" name="Bean">
<spring:property name="locations">
<spring:list>
<spring:value>file:${mule.home}/conf/PropertyFile1.properties</spring:value>
<spring:value>file:${mule.home}/conf/PropertyFile2.properties</spring:value>
</spring:list>
</spring:property>
</spring:bean>
这样的文件会被首先加载,应用-1或应用-2?你知道哪个优先吗? – insaneyogi
查看我的回答编辑 –
所以我的问题确实是如果没有指定订单属性,&我有两个属性文件设置将导致错误,或者是否有一个默认排序?如果是的话,默认排序是什么。 – insaneyogi