`
starbhhc
  • 浏览: 632769 次
  • 性别: Icon_minigender_2
  • 来自: 深圳
社区版块
存档分类
最新评论

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

    博客分类:
  • java
 
阅读更多

两天平台中集成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

 

 

 

 

 

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics