spring环境测试
比如有个service类:(再建个接口类)
package com.tydic.jtcrm.batch.service.impl; import java.util.Map; import javax.annotation.Resource; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import com.tydic.jtcrm.batch.service.BatchRealNameService;
import com.tydic.jtcrm.common.service.ParentService; @Service
public class BatchRealNameServiceImpl extends ParentService implements BatchRealNameService{ private final static Logger logger = LoggerFactory.getLogger(BatchRealNameServiceImpl.class); //根据待处理文件id 查询对应数据记录数量
@Override
public Map queryOneByHandleStatus(String handleStatus){
Map provMap = this.selectOne("ds1", "batchReal.queryOneByHandleStatus",handleStatus);
return provMap;
} }
【需要注意的是:要加@service注解】
然后在其他随便一个类里写个main方法即可测试:
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("classpath:spring-config/disconf.beans.xml");
BatchRealNameService service = (BatchRealNameService)context.getBean("batchRealNameServiceImpl");
Map map = service.queryOneByHandleStatus("1100");
System.out.println(map);
}
【这里需要注意的是:
1、ApplicationContext 对象创建时后面参数要写 spring 配置文件的路径。
2、getBean后面的参数要写对应类的首字母小写。 即实际类是 BatchRealNameServiceImpl 而加载bean时,要写成 batchRealNameServiceImpl
】
spring环境测试的更多相关文章
- Quartz —— Spring 环境下的使用
一.在 Spring 环境下 Quartz 的使用超级简单. 二.具体使用 1.添加对应的 spring-quartz 的配置文件. 2.新建要执行定时任务的目标类和目标方法,不需要继承 Job 接口 ...
- Shiro —— Spring 环境下的使用
一.使用 1.搭建基础环境 (1)导入 Spring 和 Shiro 的 Jar 包 正常导入 spring jar包 导入日志包 log4j-1.2.15.jar slf4j-api-1.6.1.j ...
- Spring TestContext测试框架搭建
同样是测试,JUnit和Spring TestContext相比,Spring TestContext优势如下: 1.Spring TestContext可以手动设置测试事务回滚,不破坏数据现场 2. ...
- 真正意义上的spring环境中的单元测试方案spring-test与mokito完美结合
真正意义上的spring环境中的单元测试方案spring-test与mokito完美结合 博客分类: java 测试 单元测试SpringCC++C# 一.要解决的问题: spring环境中 ...
- spring环境的搭建及作用和定义<一>
问题?spring的定义及作用.spring的环境搭建 一.spring的定义及作用 1.spring由Rod Johnson创建的一个开源框架,它是为了解决企业应用开发的复杂性而创建的.框架的主要优 ...
- 移动商城第三篇【搭建Mybatis和Spring环境、编写Dao、Service在Core模块】
Mybatis和Spring环境搭建 由于我们的所编写的dao层.service代码可能前台和后台都需要用到的,因此我们把环境搭建在core模块中 逆向工程 首先,我们要做的就是品牌管理,我们首先来看 ...
- 在eclipse中,使用spring tool suite配置spring环境
本人第一次接触spring,在经过一天的努力之后,终于成功配置了spring环境. 使用spring tool suite配置 1.打开eclipse,选择help->Eclipse marke ...
- Spring 环境与profile(二)——Properties with Spring
1. 简述 Spring profile用例,分3个场景(Test, Dev, Prod)相对Spring 环境与profile(一)——超简用例多了根据具体的profile获取对应的Properti ...
- Spring MVC测试框架
原文链接:http://jinnianshilongnian.iteye.com/blog/2004660 Spring MVC测试框架详解——服务端测试 博客分类: springmvc杂谈 spri ...
随机推荐
- 第三个Sprint ------第五天
显示计算对错代码 package com.app.senior_calculator; import java.math.BigDecimal; import java.util.EmptyStack ...
- PAT 1083 是否存在相等的差
https://pintia.cn/problem-sets/994805260223102976/problems/994805260780945408 给定 N 张卡片,正面分别写上 1.2.…… ...
- php 文件上传 $_FILES 错误码
假设文件上传字段的名称file_name,则: $_FILES['file_name']['error']有以下几种类型 1.UPLOAD_ERR_OK 其值为 0,没有错误发生,文件上传成功. 2. ...
- 转载: 一、linux cpu、内存、IO、网络的测试工具
来源地址: http://blog.csdn.net/wenwenxiong/article/details/77197997 记录一下 以后好找.. 一.linux cpu.内存.IO.网络的测试工 ...
- React props传变量
<!DOCTYPE html><html><head lang="en"> <meta charset="UTF-8" ...
- JS文件的写入
1.引入filesaver.js插件: 2.JS: 方法一:var file = new File(["欢迎访问 hangge.com"], "文件导出测试.txt&qu ...
- the project already contains a form or module named pcm001怎麼解決
the project already contains a form or module named pcm001怎麼解決 菜单Project -> Remove from project.. ...
- Windows server 2008 r2下载地址和激活破解方法
Windows 7发布了服务器版本——Windows Server 2008 R2.同2008年1月发布的Windows Server 2008相比,Windows Server 2008 R2继续提 ...
- python之tkinter使用-Grid(网格)布局管理器
# 使用tkinter编写登录窗口 # Grid(网格)布局管理器会将控件放置到一个二维的表格里,主控件被分割为一系列的行和列 # stricky设置对齐方式,参数N/S/W/E分别表示上.下.左.右 ...
- LODOP打印控件关联输出各内容
Lodop打印控件利用SET_PRINT_STYLEA里面的“LinkedItem”可以把多个独立的内容关联起来,让它们顺序打印.这样,就可以实现很多效果,例如一些内容紧跟着表格下方输出,关联表格后就 ...