如何根据环境在 Mule ESB 3.9.0 中加载属性文件?
How to load properties file in Mule ESB 3.9.0 as per the environment?
我正在开发 Mule ESB 版本 3.9.0 社区版。
我必须将 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 配置文件中,我定义了 属性-placeholder 如下:
<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
您需要在 MULE_HOME/conf/wrapper.conf.
中将 env 定义为 Java 属性
示例:
wrapper.java.additional.23=-Denv=prod
将文件中以前未使用的任何数字代替 23 用于其他属性。
我正在开发 Mule ESB 版本 3.9.0 社区版。 我必须将 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 配置文件中,我定义了 属性-placeholder 如下:
<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
您需要在 MULE_HOME/conf/wrapper.conf.
中将 env 定义为 Java 属性示例:
wrapper.java.additional.23=-Denv=prod
将文件中以前未使用的任何数字代替 23 用于其他属性。