Sprint + mybatis 编写测试
今天使用Spring 和mybatis框架编写项目,写了个测试方法方便测试,之前因为一直报空指针,注入不了,所以简单记录一下,方便以后使用

root.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
">
<import resource="classpath*:spring.xml"/>
<import resource="classpath*:spring-mybatis.xml"/>
</beans>
测试RedisTest.java
package org.test; import org.dao.GhksMapper;
import org.dao.KsdmdzMapper;
import org.dao.YgdmMapper;
import org.dao.YspbMapper;
import org.dao.YyghMapper;
import org.dao.ZxksMapper;
import org.junit.Before;
import org.junit.Test;
import org.service.UploadServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; /**
* 测试
*/
public class RedisTest { @Autowired
private YgdmMapper ygdmMapper; @Autowired
private YspbMapper yspbMapper; @Autowired
private GhksMapper ghksMapper; @Autowired
private YyghMapper yyghMapper; @Autowired
private KsdmdzMapper ksdmdzMapper; @Autowired
private ZxksMapper zxksMapper; @Autowired
private UploadServiceImpl uploadServiceImpl; @Before
public void init(){
ApplicationContext context = new ClassPathXmlApplicationContext("classpath*:root.xml");//这里路径之前没有配对于是一直出错
ygdmMapper = (YgdmMapper)context.getBean("ygdmMapper");
yspbMapper = (YspbMapper)context.getBean("yspbMapper");
ghksMapper = (GhksMapper)context.getBean("ghksMapper");
yyghMapper = (YyghMapper)context.getBean("yyghMapper");
ksdmdzMapper = (KsdmdzMapper)context.getBean("ksdmdzMapper");
zxksMapper = (ZxksMapper)context.getBean("zxksMapper");
uploadServiceImpl = (UploadServiceImpl)context.getBean("uploadServiceImpl");
} @Test
public void test() {
//上传挂号科室代码
uploadServiceImpl.getS201();
//上传挂号医生代码
uploadServiceImpl.getS202();
//上传科室医生排班表
uploadServiceImpl.getS203();
//上传挂号医生停诊表
uploadServiceImpl.getS204();
//上传其他预约方式出退号记录
uploadServiceImpl.getS205();
//上传本平台预约的取号记录
uploadServiceImpl.getS206();
//上传排班预约数量记录
uploadServiceImpl.getS208();
//上传预约时间点记录
uploadServiceImpl.getS301();
//上传预约时间点停用记录
uploadServiceImpl.getS302();
uploadServiceImpl.getMzjcxx();
uploadServiceImpl.getZyjcxx();
} }
OK;
Sprint + mybatis 编写测试的更多相关文章
- 用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建二:配置MyBatis 并测试(2 配置spring-dao和测试)
用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建二:配置MyBatis 并测试(1 搭建目录环境和依赖) 四:在\resources\spring 下面 ...
- MyBatis编写映射文件实现增删改操作 附说明及代码
1.看一下我们接口 package cn.bdqn.mybatis.dao; import org.apache.ibatis.annotations.Select; import cn.bdqn.m ...
- Atitit.mybatis的测试 以及spring与mybatis在本项目中的集成配置说明
Atitit.mybatis的测试 以及spring与mybatis在本项目中的集成配置说明 1.1. Mybatis invoke1 1.2. Spring的数据源配置2 1.3. Mybatis ...
- Struts2+Spring+Mybatis+Junit 测试
Struts2+Spring+Mybatis+Junit 测试 博客分类: HtmlUnit Junit Spring 测试 Mybatis package com.action.kioskmoni ...
- XCode中的单元测试:编写测试类和方法(内容意译自苹果官方文档)
当你在工程中通过测试导航栏添加了一个测试target之后, xcode会在测试导航栏中显示该target所属的测试类和方法. 这一章演示了怎么创建测试类,以及如何编写测试方法. 测试targets, ...
- 使用Spring的Property文件存储测试数据 - 编写测试和调用测试数据
准备好测试数据后,我们可以开始编写测试了,在测试用例中调用我们property文件中的测试数据. 我自己写了一个TestCase作为所有测试类基类,基类中定义了两个变量来代表之前建好的两个测试数据文件 ...
- 编写测试类,了解ArrayList的方法
这篇文章主要介绍了C#中动态数组用法,实例分析了C#中ArrayList实现动态数组的技巧,非常具有实用价值,需要的朋友可以参考下 本文实例讲述了C#中动态数组用法.分享给大家供大家参考.具体分析如下 ...
- myBatis 基础测试 表关联关系配置 集合 测试
myBatis 基础测试 表关联关系配置 集合 测试 测试myelipse项目源码 sql 下载 http://download.csdn.net/detail/liangrui1988/599388 ...
- 用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建二:配置MyBatis 并测试(1 构建目录环境和依赖)
引言:在用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建一 的基础上 继续进行项目搭建 该部分的主要目的是测通MyBatis 及Spring-dao ...
随机推荐
- 【python】python内存管理摘要
a = 1 id(a) == id(1) 每次退出ipython重新进入,这个Id都会不一样 sys.getrefcount(a) 可以计数某个对象的引用次数,是原来的次数+1 垃圾回收 使用gc包 ...
- android textview xml 属性设置
android:ems 设置TextView的宽度为N个字符的宽度. android:maxems 设置TextView的宽度为最长为N个字符的宽度.与ems同时使用时覆盖ems选项. andr ...
- (十一)java循环结构
while(循环的条件) {循环的语句} int a = 1; while(a < 5) { System.out.println(a);//1,2,3,4 a++; } System.out. ...
- Linux 安全rm
先将shell脚本放在某个全局路径下,如/usr/local/bin #!/bin/sh # safe rm # Don't remove the file, just move them to a ...
- Lua学习笔记(1)
1.chunk是可以把Lua识别并执行的代码.chunk可以是单条语句,也可以是一系列语句的组合,还可以是函数,或是一个代码文件,交互模式下的每条指令(一行或多行)都是一个chunk交互模式下,判断指 ...
- 解决Net内存泄露原因
Net内存泄露原因及解决办法 https://blog.csdn.net/changtianshuiyue/article/details/52443821 什么是.Net内存泄露 (1).NET 应 ...
- ORACLE系统表大全
下面全面是对Oracle系统表的一些介绍: 数据字典dict总是属于Oracle用户sys的. 1.用户: select username from dba_users; 改口令 alter user ...
- AbstractIdleService
该类有一个startup和shutdown方法,启动此服务或者结束此服务的时候可以调用. Runtime.getRuntime().addShutdownHook(new Thread() {@Ove ...
- 在actionbar中加入item的方法
首先在menu文件夹中创建post.xml <?xml version="1.0" encoding="utf-8"?> <menu xmln ...
- base64图片上传,并根据不同项目进行智能修改图片
前台传图片的base64格式,后台处理方式//处理图片信息 返回对应的路径public function uploadBaseIma($imgArr){ $result = array(); //将路 ...