今天使用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 编写测试的更多相关文章

  1. 用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建二:配置MyBatis 并测试(2 配置spring-dao和测试)

    用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建二:配置MyBatis 并测试(1 搭建目录环境和依赖) 四:在\resources\spring 下面 ...

  2. MyBatis编写映射文件实现增删改操作 附说明及代码

    1.看一下我们接口 package cn.bdqn.mybatis.dao; import org.apache.ibatis.annotations.Select; import cn.bdqn.m ...

  3. Atitit.mybatis的测试  以及spring与mybatis在本项目中的集成配置说明

    Atitit.mybatis的测试  以及spring与mybatis在本项目中的集成配置说明 1.1. Mybatis invoke1 1.2. Spring的数据源配置2 1.3. Mybatis ...

  4. Struts2+Spring+Mybatis+Junit 测试

    Struts2+Spring+Mybatis+Junit 测试 博客分类: HtmlUnit Junit Spring 测试 Mybatis  package com.action.kioskmoni ...

  5. XCode中的单元测试:编写测试类和方法(内容意译自苹果官方文档)

    当你在工程中通过测试导航栏添加了一个测试target之后, xcode会在测试导航栏中显示该target所属的测试类和方法. 这一章演示了怎么创建测试类,以及如何编写测试方法. 测试targets, ...

  6. 使用Spring的Property文件存储测试数据 - 编写测试和调用测试数据

    准备好测试数据后,我们可以开始编写测试了,在测试用例中调用我们property文件中的测试数据. 我自己写了一个TestCase作为所有测试类基类,基类中定义了两个变量来代表之前建好的两个测试数据文件 ...

  7. 编写测试类,了解ArrayList的方法

    这篇文章主要介绍了C#中动态数组用法,实例分析了C#中ArrayList实现动态数组的技巧,非常具有实用价值,需要的朋友可以参考下 本文实例讲述了C#中动态数组用法.分享给大家供大家参考.具体分析如下 ...

  8. myBatis 基础测试 表关联关系配置 集合 测试

    myBatis 基础测试 表关联关系配置 集合 测试 测试myelipse项目源码 sql 下载 http://download.csdn.net/detail/liangrui1988/599388 ...

  9. 用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建二:配置MyBatis 并测试(1 构建目录环境和依赖)

    引言:在用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建一   的基础上 继续进行项目搭建 该部分的主要目的是测通MyBatis 及Spring-dao ...

随机推荐

  1. 理解 Promise 过程

    /** new Promise(fn1).then(function(val){ console.log(val); }) 主要是把 then 的函数抽取出来 , 利用闭包存放在 callback中, ...

  2. CUDA Samples:Vector Add

    以下CUDA sample是分别用C++和CUDA实现的两向量相加操作,参考CUDA 8.0中的sample:C:\ProgramData\NVIDIA Corporation\CUDA Sample ...

  3. hihocoder-1483区间价值 (二分+尺取法)

    题目链接: 区间价值 给定n个数A1...An,小Ho想了解AL..AR中有多少对元素值相同.小Ho把这个数目定义为区间[L,R]的价值,用v[L,R]表示. 例如1 1 1 2 2这五个数所组成的区 ...

  4. Java进阶面试问题列表

    面向对象编程的基本理念与核心设计思想 解释下多态性(polymorphism),封装性(encapsulation),内聚(cohesion)以及耦合(coupling). 继承(Inheritanc ...

  5. 最简单的记录程序运行时间的方法:[记录PHP程序运行消耗时间]

    比较实用的debug方法:具体参考地址已经记不清了,这里重写成类方便调用 /** * @author logonmy@126.com * @Date: 13-7-23 * @desc example ...

  6. HDU - 6178:Monkeys (贪心&树上最大匹配输&输入优化)

    There is a tree having N vertices. In the tree there are K monkeys (K <= N). A vertex can be occu ...

  7. bzoj 3192 删除物品

    Written with StackEdit. Description 箱子再分配问题需要解决如下问题: (1)一共有\(N\)个物品,堆成\(M\)堆. (2)所有物品都是一样的,但是它们有不同的优 ...

  8. [BZOJ5133][CodePlus2017年12月]白金元首与独舞

    bzoj luogu 题意 给你一个\(n*m\)的网格,每个位置上有一个箭头指向上或下或左或右.有些位置上还没有箭头,现在要求你在这些没有箭头的位置上填入箭头,使得从网格的任意一个位置开始,都可以沿 ...

  9. 因实现本地浏览器访问nginx修改配置文件后,安装vsftpd失败

    解决方法如下(修改dns配置) vi /etc/resolv.conf 在此文件最后加入:nameserver 8.8.8.8 如果没有vi编辑器可用: echo "nameserver 8 ...

  10. 微软发布WCF教程及大量示例

    继前面 微软公司发布Windows Communication Foundation (WCF)和Windows CardSpace的示例程序之后,微软今天又发布了WF的教程和大量示例,对于学习WF的 ...