- 需要junit 和 spring-test-version jar包
- @RunWith(SpringJUnit4ClassRunner.class)
- @ContextConfiguration(locations = "classpath:applicationContext*.xml")
- 如普通spring注解注解使用就可以了
- 例子
@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); } }
时间: 2024-12-25 09:03:58