2015-11-06 67 views
1

根据环境,我已经配置了一个config.xml文件来选择适当的属性文件。我正在使用Apache Camel作为Spring Boot应用程序运行。无法使用外部文件解析字符串值中的占位符

配置看起来像这样。

<bean id="properties" 
    class="org.apache.camel.component.properties.PropertiesComponent"> 
    <property name="locations" ref="locations" /> 
</bean> 

<bean id="bridgePropertyPlaceholder" 
    class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer"> 
    <property name="locations" ref="locations" /> 
    <property name="ignoreUnresolvablePlaceholders" value="true" /> 
</bean> 

<beans profile="dev"> 
<util:list id="locations"> 
    <value>classpath:config/users.properties</value> 
    <value>classpath:config/application.properties</value> 
    <value>classpath:config/application-dev.properties</value> 
</util:list> 

<beans profile="test"> 
<util:list id="locations"> 
    <value>file:${project.dir}/config/users.properties</value> 
    <value>file:${project.dir}/config/application.properties</value> 
</util:list> 

当使用测试配置文件我想用在配置中定义的外部文件(因为我不想提交的用户名/密码回购)。这似乎工作正常。

但是,我users.properties文件包含:

username=myusername 
password=mypassword 

和我application.properties包含:

loginParameters=username=${username}&password=${password} 

运行java -jar myjar.jar --spring.profiles.active=test当我遇到:

​​

它清楚地加载属性文件,因为它指出:

Loading properties file from URL: file:...../users.properties 
Loading properties file from URL: file:...../application.properties 
Bridging Camel and Spring property placeholder configurer with id: bridgePropertyPlaceholder 
... 

然后发生异常。如何解决application.properties文件无法识别users.properties中定义的属性的问题?运行dev-profile时,一切正常。

回答

0

在您的应用程序属性中,使用$ simple {username}和$ simple {password}告诉Camel将值放在那里。

+0

应该评论 –

相关问题