今天使用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. EditPlus保存时不生成bak文件(转)

    如何设置EditPlus保存时不生成bak文件 EditPlus是一个强大的编辑工具,不单单是编辑文字强大,很多的刚开始学习编程语言的初学者会选择它,例如html,js,php,java.小编刚开始学 ...

  2. NODE 性能优化

    五个手段 “如果你的 node 服务器前面没有 nginx, 那么你可能做错了.”—Bryan Hughes Node.js 是使用 最流行的语言— JavaScript 构建服务器端应用的领先工具 ...

  3. include和application

    include指令 语法:<%@ include  file=”路径+文件名” %> 把指定的文件包含到当前jsp中. application(应用的全局变量) 实现用户之间的数据共享 常 ...

  4. 如何复制一个java对象(浅克隆与深度克隆)

    在项目中,有时候有一些比较重要的对象经常被当作参数传来传去,和C语言的值传递不同,java语言的传递都是引用传递,在任何一个地方修改了这个对象的值,就会导致这个对象在内存中的值被彻底改变.但是很多时候 ...

  5. 深度学习实战-----0001(移植反向传播Python to c++)

    1. https://mattmazur.com/2015/03/17/a-step-by-step-backpropagation-example/  老外教程 2. https://github. ...

  6. BaseCommand

    import java.io.Serializable; import android.util.Log; public class BaseCommand implements Serializab ...

  7. 剑指offer-第六章面试中的各项能力之总结

  8. c# 统计运行时间

    long startTime = Environment.TickCount; long endTime = Environment.TickCount; long totalTime = endTi ...

  9. Maven build标签

    前言: <build >设置,主要用于编译设置 1.分类 在Maven的pom.xml文件中,存在如下两种<build>: (1)全局配置(project build) 针对整 ...

  10. 转:使用django-admin.py创建django工程

    原文:http://blog.csdn.net/a921800467b/article/details/8257352 安装Django首先需要安装数据库,可选的数据库有好几种,我选择的是MySQL数 ...