$Value{}ntException: Could not resolve placeholder 'KEY' in string value "${

springmvc 中@Value("${KEY}")  出现 $Value{}ntException: Could not resolve placeholder 'KEY' in string value "${

 错误。

 


down vote

Don't use multiple  tags, refer below code for the same and also make sure you have a key "com.ibm.CORBA.securityServerHost" with a value in either of your property file.


<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
   <property name="location">
      <list>
         <value>classpath:em-management.propertiesvalue>
         <value>file:///opt/ass/swp/conf/platform.properties
      list>
   property>
   <property name="ignoreUnresolvablePlaceholders" value="true"/>
bean>

 

错误原因: 我在applicationContext-dao.xml和 redis-config.xml分别用了扫描器


如果再在这两个文件里扔一个扫描constant目录下属性文件的扫描器 那么同时存在两个:
此时要加上
ignore-unresolvable="true"

 

 


$Value{}ntException: Could not resolve placeholder 'KEY' in string value

 

 

 

我又在applicationContext-service.xml 中又加载了一个属性文件
   classpath:constant/constant.properties     发现这个文件在我使用的时候@Value("${KEY}") 所注入的值直接是引号里面的 “${KEY}”,所以没有任何效果。
 
如果上面代码配置在springmvc文件中有效,且如果换成下面配置也有效, 
 
 


也就是说我不在同一个文件中使用<context:property-placeholder就不需要添加

ignore-unresolvable="true"

 

 

 

 

你可能感兴趣的:(后端开发,各种报错,spring,mvc,Value)