今天使用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. UI- UINavigationController UITabBarController 使用总结

    #pragma mark - UINavigationController UITabBarController  ====================================== 控制器 ...

  2. 发现的好东西——bitset

    先向各位大佬介绍一个水题 任何一个正整数都可以用2的幂次方表示.例如 137=2^7+2^3+2^0 同时约定方次用括号来表示,即a^b 可表示为a(b). 由此可知,137可表示为: 2(7)+2( ...

  3. 2017.11.16 STM8L052 温度控制器

    1 J-link和ST-link的兼容性 STM8只能用ST-link.J-link兼容所有的(大部分而已)的ARM内核IC mark:  http://bbs.eeworld.com.cn/thre ...

  4. MpVue开发之框架的搭建

    npm install --global  vue-cli vue脚手架 vue init mpvue/mpvue-quickstart  my-project 创建一个基于mpvue-quickst ...

  5. Sphinx 匹配模式

    所谓匹配模式就是用户如何根据关键字在索引库中查找相关的记录. SPH_MATCH_ALL, 匹配所有查询分词(默认模式); 如“手机配件”,不匹配 “我有一部手机”,但可以匹配 “手机坏了,需要找配件 ...

  6. Android UI之LinearLayout详解

    ※※※摘自http://www.cnblogs.com/salam/archive/2010/10/20/1856793.html LinearLayout是线性布局控件,它包含的子控件将以横向或竖向 ...

  7. GlassFish的安装与使用(Windows)

    前言 Glassfish是一款由Sun公司开发的(现由甲骨文公司赞助)开源的免费的应用服务器,它既是EJB容器也是WEB容器.Glassfish支持最新版的Java EE标准. Glassfish与T ...

  8. fn project 扩展

    目前支持的扩展方式   Listeners - listen to API events such as a route getting updated and react accordingly. ...

  9. Swift-ScrollView轮播图的简易封装和使用

    不多说,轮播图是开发中必要一项技能,直接上代码: 先说我的思路:首次继承于UIScrollView类自定义MyScrollView,在MyScrollView里自定制方法,func creatMySc ...

  10. yum 报错

    Loaded plugins: fastestmirror, prestoLoading mirror speeds from cached hostfileCould not retrieve mi ...