1. spring 开发中单元测试时的初始化参数(加载日志配置文件、加载 spring 配置文件)
- 代码片段
DOMConfigurator.configure ("./files/log4j.xml"); // 加载日志文件
ApplicationContext contextConfig = new FileSystemXmlApplicationContext("./files/base_beans.spring.xml"); // 加载 spring 文件
PrototypeEntity prototype = contextConfig.getBean("prototypeEntity", PrototypeEntity.class); // 通过 bean id 获取对象
// bean 的注入、scope="prototype" 表示多例
<bean id="prototypeEntity" scope="prototype" class="com.aiden.demo.base.entites.PrototypeEntity">
<property name="testService" ref="testService"/>
</bean>
- 依赖 jar 包

- 测试案例截图




本文介绍在Spring开发中如何进行单元测试的初始化设置,包括加载日志配置文件和Spring配置文件的方法,并展示了通过Bean ID获取对象的过程及依赖的jar包。
6917

被折叠的 条评论
为什么被折叠?



