@Value遇到的问题


Spring注解@Value在controller无法获取到值
可以看这个博文链接:https://blog.csdn.net/Thinkingcao/article/details/80620240

如果配置错​​​​​​​完报错

Could not resolve placeholder 'jdbc.url' in string value "${jdbc.url}"
可能是因为出现了下面这种情况,去掉其中一种配置即可
@Value遇到的问题

另外想配置多个文件的话

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>classpath:jdbc.properties</value>
            ​​​​​​​<value>classpath:jdbc2.properties</value>
        </list>
    </property>
   
</bean>

或者用这种情况

<context:property-placeholder location="classpath:properties/*.properties"/>


 

相关文章:

  • 2021-09-24
  • 2021-04-14
  • 2021-12-24
  • 2021-08-31
  • 2021-11-13
  • 2021-06-18
  • 2021-04-15
  • 2021-07-03
猜你喜欢
  • 2022-02-16
  • 2021-06-23
  • 2021-07-22
  • 2022-01-28
  • 2021-09-01
  • 2021-06-14
相关资源
相似解决方案