public class ForumDaoTest {
/**
* spring 的自动装配Beans,通过@Qualifier装配指定bean
*/
@Test
public void getForumByIdTest(){
ApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
IForumDao forumDao = (IForumDao) context.getBean("forumdao");
Forum forum = forumDao.getForumById(1);
System.out.println(forum.getName());
}
}
13.在测试类ForumDaoTest的getForumByIdTest方法上右键运行,输出结果如图所示