日期:2014-05-20  浏览次数:20653 次

spring 单元测试
我在application中引入了属性文件,配置如下
Java code
<!-- 属性文件读入 -->
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>/WEB-INF/jdbc.properties</value>
                <value>/WEB-INF/hibernate.properties</value>
            </list>
        </property>
    </bean>


如果不做单元测试的话,这个路径是没问题的,我做了一个简单的登录示例,是可以运行的,但是做单元测试把aplication.xml加载的时候,它却提示WEB-INF/jdbc.properties找不到这个文件,真郁闷哦.
有什么办法可以解决吗?是不是单元测试中的都不能引用其它文件,这样的话spring的单元测试也太难做了吧

------解决方案--------------------
实在不行你就看下org.springframework.beans.factory.config.PropertyPlaceholderConfigurer这个类的解过程不就OK了。