2015-11-05 97 views
0

我使用apache駱駝2.15.1,我有三個屬性文件,這是在類路徑中的環境特定像myprop.properties, myprop-enva.properties, myprop-envb.properties. 我在camelcontext中使用propertyplaceholder,我能夠加載myprop.properties。駱駝propertyplaceholder環境特定文件

我不知道如何加載myprop-enva.properties當WebSphere env.prop = _enva

我現在的配置是這樣的..

<propertyPlaceholder location="classpath:myprop.properties" //Here I need to modify to make it work 
     id="placeholder1" /> 

我試圖改變爲location="classpath:myprop${env.prop}.properties",但它沒有工作。

回答

1

您可以使用blueprint屬性佔位符,然後將從服務器加載環境特定的cfg文件。不同的服務器 - 不同的cfg文件。

或者您可以將特定屬性文件放入包階段的包中(使用maven配置文件)。

<profiles> 
    <profile> 
     <id>production</id> 
     <activation> 
      <activeByDefault>false</activeByDefault> 
     </activation> 
     <properties> 
      <env>production</env> 
     </properties> 
    </profile> 
    <profile> 
     <id>developer</id> 
     <activation> 
      <activeByDefault>true</activeByDefault> 
     </activation> 
     <properties> 
      <env>developer</env> 
     </properties> 
    </profile> 
</profiles> 

<build> 
    <resources> 
     <resource> 
      <directory>src/main/resources</directory> 
      <excludes> 
       <exclude>props/**/*.properties</exclude> 
      </excludes> 
      <filtering>false</filtering> 
     </resource> 
     <resource> 
      <directory>src/main/resources/props/${env}</directory> 
      <filtering>true</filtering> 
     </resource> 
    </resources> 
    .......... 
</build> 
+0

目前我們使用的彈簧與駱駝,不知道我能與Spring使用藍圖的更多細節。第二個選項不適合我,因爲它打破了部署團隊的指導方針(在我的項目中)..感謝解決方案@Alelxey – bakki