如何根据环境在Mule ESB 3.9.0中加载属性文件?

时间:2019-08-23 10:18:12

标签: mule-esb

我正在研究Mule ESB版本3.9.0 Community Edition。 我必须将esb应用程序部署到不同的环境,例如dev,int,prod等。所以我做了以下工作:

mule-app.properties:
env = dev

并创建了三个属性文件:

esb-frontoffice-dev.config.properties
esb-frontoffice-int.config.properties
esb-frontoffice-prod.config.properties

现在,在ESB配置文件中,我已如下定义了属性占位符:

  <context:property-placeholder location="esb-frontoffice-${env}.config.properties"/>

然后,在构建工件之后,我将其部署在Mule ESB 3.9.0运行时服务器中。但我收到以下错误:

Caused by: java.io.FileNotFoundException: class path resource [esb-frontoffice-${env}.config.properties] cannot be opened because it does not exist
        at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172) ~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
        at org.springframework.core.io.support.EncodedResource.getInputStream(EncodedResource.java:150) ~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
        at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:98) ~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
        at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:175) ~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
        at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:156) ~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
        at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:80) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
        ... 36 more

1 个答案:

答案 0 :(得分:1)

您需要在MULE_HOME / conf / wrapper.conf中将env定义为Java属性。

示例:

wrapper.java.additional.23=-Denv=prod

将文件中先前未使用的任何数字用于其他属性,而不是23。