今天使用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. VS2010 将程序发布至网站时,发生错误“未能给 bin/Debug/publish//setup.exe 签名“

    VS2010 将程序发布至网站时,发生错误“未能给 bin/Debug/publish//setup.exe 签名“  错误:   因为某项目未能生成,所以无法发布. ---------------- ...

  2. Android的方法和属性(2)

    1.RadioButton(单选按钮) 嵌入到RsdioGroup中实现单选效果 android:checkedButton="radio的id值" int getCheckedR ...

  3. CentOS下安装w3m,及w3m的使用

    centos下安装软件的命令不是apt-get,而是yum,如果安装w3m,利用sudo yum install w3m w3m-img -y即可 △△△△△△△△如果你用的是centos或readh ...

  4. WPF:XAML概述

    简介 XAML是eXtensible Application Markup Language可扩展应用程序标记语言,它是微软公司为构建应用程序用户界面而创建的一种新的描述性语言.XAML提供了一种便于 ...

  5. 谨慎安装Python3.7.0,SSL低版本导致Pip无法使用

    最新新配置了一台服务器.安装 的时候直接使用了最新的Python 3.7最新版本. 安装成功,编译成功.但是用pip 安装包的时候提示:pip is configured with locations ...

  6. dubbo-demo安装运行指南

    步骤步骤:1.安装JDK:2.安装Tomcat:3.安装Zookeeper:4.安装Dubbo: 修改Consumer配置文件

  7. weblogic11g的安装使用

    一.JDK的安装 下载linux环境下的jdk安装文件,本文资源下载:jdk-7u79-linux-x64.tar.gz 将jdk放到linux制定目录下,执行以下命令进行解压操作 tar -zxvf ...

  8. FastAdmin 增删改查在哪里?

    FastAdmin 增删改查在哪里? 一键生成 CRUD think crud -t test -u 1 执行命令合会在 controller 下生成 Test.php 控制器. 但是这个文件里确看不 ...

  9. laravel 网站速率优化

    https://segmentfault.com/a/1190000009954966

  10. centos7防火墙 启动和关闭

    CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙.firewall:systemctl start firewalld.service   #启动firewa ...