首页 > 编程语言 > 详细

spring test

时间:2017-08-13 23:12:04      阅读:159      评论:0      收藏:0      [点我收藏+]
  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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!