码迷,mamicode.com
首页 > 编程语言 > 详细

spring test

时间:2017-08-13 23:25:48      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:test   spring   

  1. 需要junit 和 spring-test-version jar包

  2. @RunWith(SpringJUnit4ClassRunner.class)

  3. @ContextConfiguration(locations = "classpath:applicationContext*.xml")

  4. 如普通spring注解注解使用就可以了

  5. 例子

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:spring/spring-context.xml")
public class NoticeScopeDaoTest {

	@Resource
	private NoticeScopeDao noticeScopeDao;
	
	@Test
	public void testBatchSave() {
		List<NoticeScope> noticeScopeList = new ArrayList<>();
		NoticeScope demo1 = new NoticeScope();
		demo1.setNoticeid(11111111L);
		demo1.setSubjectid(222222L);
		demo1.setSubjecttype(2);
		noticeScopeList.add(demo1);
		NoticeScope demo2 = new NoticeScope();
		demo2.setNoticeid(11111111L);
		demo2.setSubjectid(222222L);
		demo2.setSubjecttype(2);
		noticeScopeList.add(demo2);
		noticeScopeDao.batchSave(noticeScopeList);
	}

}


spring test

标签:test   spring   

原文地址:http://881206524.blog.51cto.com/10315134/1955918

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!