@Value遇到的问题

             @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"/>