spring 配置 junit
package cn.hefen.mall.app; import cn.hefen.mall.app.model.ResultMap;
import cn.hefen.mall.app.model.UserNotice;
import cn.hefen.mall.app.web.controller.UserController;
import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc; import java.util.List; /**
* 创建时间 2018/1/30 8:32
*
*
* @author 王海明
*/
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration("classpath:dispatcher-servlet.xml")
public class BaseSpringTest { @Autowired
private UserController controller; @Test
public void doTest() {
ResultMap userNotice = controller.findUserNotice(125, 0, 5);
System.out.println();
System.out.println(userNotice);
}
}
spring test ,servlet 版本需要在 3.1.0以上...使用 servlet 2.5 会报错....
如果 spring Mvc,spring 在一个 配置文件里面..加上 @WebAppConfiguration 注解
spring 配置 junit的更多相关文章
- Spring系列之新注解配置+Spring集成junit+注解注入
Spring系列之注解配置 Spring是轻代码而重配置的框架,配置比较繁重,影响开发效率,所以注解开发是一种趋势,注解代替xml配置文件可以简化配置,提高开发效率 你本来要写一段很长的代码来构造一个 ...
- 使用Spring配合Junit进行单元测试的总结
最近公司的项目和自己的项目中都用到了spring集成junit进行单元测试,总结一下几种基本的用法: 1.直接对spring中注入的bean进行测试(以DAO为例): 在测试类上添加@RunWith注 ...
- 【Spring】Junit加载Spring容器作单元测试
如果我们需要对我们的Service方法作单元测试,恰好又是用Spring作为IOC容器的,我们可以这么配置Junit加载Spring容器,方便做单元测试. > 基本的搭建 (1)引入所需的包 & ...
- spring 配置 Java配置类装配bean
https://www.cnblogs.com/chenbenbuyi/p/8457700.html 自动化装配的确有很大的便利性,但是却并不能适用在所有的应用场景,比如需要装配的组件类不是由自己的应 ...
- Spring配置连接池
---------------------siwuxie095 Spring 配置连接池 1.Spring 配置内置连接 ...
- Maven聚合、Maven仓库jar包以及Spring+MyBatis+JUnit+Maven整合测试的搭建过程
一.Maven将父项目创建到父项目的内部 在父项目的pom.xml上 点右键,选择maven-->new-->maven module project 二.Maven聚合 在某个项目的p ...
- 【Spring】Junit加载Spring容器作单元测试(整理)
[Spring]Junit加载Spring容器作单元测试 阅读目录 >引入相关Jar包 > 配置文件加载方式 > 原始的用法 > 常见的用法 > 引入相关Jar包 一.均 ...
- Spring之junit测试集成
简介 Spring提供spring-test-5.2.1.RELEASE.jar 可以整合junit. 优势:可以简化测试代码(不需要手动创建上下文,即手动创建spring容器) 使用spring和j ...
- ssm整合——Spring配置(2)
配置Spring 1. 环境准备 使用之前搭建Mabatis的环境 1.1 新建目录 新建spring的service业务逻辑包 在resources目录下新建spring的配置文件:applicat ...
随机推荐
- 【转载】C语言综合实验1—学生信息管理系统
http://www.cnblogs.com/Anker/archive/2013/05/06/3063436.html 实验题目:学生信息管理系统 实验要求:用户可以选择1-7可以分别进行学生信息的 ...
- Webrtc服务器搭建<转>
http://blog.csdn.net/zqf_office/article/details/49851209
- Android中Activity之间的数据传递
在开发中,我们经常涌用到Activity,那么既然用到了Activity,就一定免不了在两个或者多个Activity之间传递数据.这里我们先说一说原理,然后在看看代码和例子. 情况A:我们需要从Act ...
- 基于Flask框架的Python web程序的开发实战 <一> 环境搭建
最近在看<Flask Web开发基于Python的Web应用开发实战>Miguel Grinberg著.安道译 这本书,一步步跟着学习Flask框架的应用,这里做一下笔记 电脑只安装一个P ...
- mysql case
1.table CREATE TABLE `lee`(`id` INT(10) NOT NULL auto_increment,`name` varchar(20) DEFAULT null,`bir ...
- JAVA之数组队列
package xxj.datastructure0810; import java.util.Random; public class DataStructure { /** * @param ar ...
- C++面向对象类的实例题目六
问题描述: 编写一个程序计算两个给定长方形的面积,其中在设计类成员函数addarea()(用于计算两个长方形的总面积)时使用对象作为参数. 程序代码: #include<iostream> ...
- Opengl创建几何实体——四棱锥和立方体
//#include <gl\glut.h>#include <GL\glut.h>#include <iostream> using namespace std; ...
- Blender 工具使用——显示键盘和鼠标操作
Blender 工具使用--显示键盘和鼠标操作 Blender自己本身就带有显示按键和鼠标的功能,就是3D View: Screencast Keys插件. 打开 File(文件) -> Use ...
- 1054D&EZOJ #93 Changing Array
传送门 分析 我们可以对一个数列求前缀和,如果pre[l]=pre[r]则我们可以知道区间[l,r]一定不合法 于是我们就要让不合法的区间尽量少 我们知道对于一个数$x$,他只受x和$(2^k-1)$ ...