Could not resolve placeholder '***' in string value "${****}"

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/baidu_34750904/article/details/79410126

这里记录下,Spring 运行单元测试时报这个错误,基本上是由于单元测试的配置文件覆盖不全的问题导致的。在spring 的配置文件中,我这里叫做spring-config.xml 文件中,找到属性文件读入的bean。如下:

<!-- 属性文件读入 -->
    <bean name="configProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:*.properties</value>
            </list>
        </property>
    </bean>

value 标签中classpath 的范围过小,使得根本找不到对应的资源文件,在classpath后面加一个*,扩大读取范围就搞定了~亲测,可解决部分资源文件读取不到的问题。

猜你喜欢

转载自blog.csdn.net/baidu_34750904/article/details/79410126