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

  2. @RunWith(SpringJUnit4Cla***unner.class)

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

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

  5. 例子

@RunWith(SpringJUnit4Cla***unner.class)@ContextConfiguration(locations = "classpath:spring/spring-context.xml")public class NoticeScopeDaoTest {	@Resource	private NoticeScopeDao noticeScopeDao;		@Test	public void testBatchSave() {		List
 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); }}