spring同时集成redis和mongodb时遇到多个资源文件加载的问题

两天平台中集成redis和mongodb遇到一个问题

单独集成redis和单独集成mongodb时都可以正常启动程序,但是当两个同时集成进去时就会报以下问题:

Could not resolve placeholder 'mongo.port' in string value "${mongo.port} 

 

 

在spring的xml配置文件中当有多个*.properties文件需要加载时。

应该这样使用使用

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

<property name="locations">

<list>

<value>classpath*:mongodb.properties</value>

</list>

</property>

<property name="ignoreUnresolvablePlaceholders" value="true" /> 

</bean>

或者

<context:property-placeholder location="classpath:properties/mongodb.properties" ignore-unresolvable="true"/>

 

但是 ignore-unresolvable="true" 和 <property name="ignoreUnresolvablePlaceholders" value="true" /> 这两个属性值必须为true

 

 

 

 

 

 

 

 

猜你喜欢

转载自starbhhc.iteye.com/blog/2298191