1.引入所需jar包,spring-3.2*.jar、junit4.x.jar等;
2.配置sping-test.xml文件,并将文件放在源路径下:
3.编写单元测试类:
1 @RunWith(SpringJUnit4ClassRunner.class) //使用junit4进行测试 2 @ContextConfiguration(locations={"classpath*:spring-test.xml"})//加载spring文件 3 @TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)//配置事务 4 public class MyWebTest{ 5 6 @Resource 7 private JdbcTemplate jdbcTemplate; //注入jdbctemplate类 8 9 @Test10 public void test01(){11 List