spring单元测试junit及spring配置
来源:互联网 发布:mac电脑淘宝秒杀软件 编辑:程序博客网 时间:2024/05/16 19:18
完整的junit单元测试及spring配置
XXXXTest.java
private static ClassPathXmlApplicationContext ctx;
/**
* 装入spring配置文件,注入bean
* @throws Exception
*/
@Before
public void setUp() throws Exception {
try {
String[] configLocation = {
"classpath*:spring/applicationContext-*.xml" };
ctx = new ClassPathXmlApplicationContext(configLocation);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void test() {
try {
ClassName aclassobj= (ClassName)ctx.getBean("xmlClassName");
aclassobj.method();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
spring配置文件
1、applicationContext-bean.xml
配置xmlClassName中使用到的成员变量,自动装入,注意ClassName中要有set,get函数
如:
<bean id="xmlClassName" class="ClassNamePackage">
<property name="="***service" ref="***service"/>
<property name="userName" value="${userName}"/>//配置文件中注入
</bean>
2、applicationContext-service.xml
<bean id="="***service" class="="***servicePackage" >
<property name="Path" value="$path}" />//配置文件中注入
</bean>
- spring单元测试junit及spring配置
- Spring Junit单元测试
- Spring + JUnit进行单元测试
- Struts2+Spring+Junit单元测试
- junit spring 注解 单元测试
- spring整合junit单元测试
- SPRING+JUNIT单元测试s
- Spring Junit 单元测试实例
- Spring Boot Junit单元测试
- spring junit 单元测试
- Junit配合Spring单元测试
- Spring Junit单元测试
- Spring Boot Junit单元测试
- spring+junit进行单元测试
- Spring Boot Junit单元测试
- Spring Boot Junit单元测试
- Spring Boot Junit单元测试
- mybatis+spring junit单元测试
- 《Motion Design for iOS》(四)
- 导航条NavigatinBar
- Bluedroid的结构和代码分布
- boost::program_options挖坑待填
- ERROR: invalid memory alloc request size 1111005384
- spring单元测试junit及spring配置
- QQ群裂变引流做CPA,日引500+流量
- boost::filesystem挖坑待填
- Android 系统服务一览表
- Guava 学习
- 使用Angularjs、jQuery在手机上实现滑动条到底自动加载更多功能
- plsql快捷键及使用优化
- android 控件对齐方式
- 同步的机制(一)