1.导入好jre 包
2.放置好配置文件
3.整合
hibernate和spring(保证数据库)
4.测试hibernate和spring的整合
public class SpringTest {
private
ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
@Test
public void testLog() {
Log log = LogFactory.getLog(getClass());
log.
debug("debug");
log.info("info");
log.warn("warn");
log.error("error");
log.fatal("fatal");
}
// 测试SessionFactory
@Test
public void testSessionFactory() {
SessionFactory sessionFactory = (SessionFactory) ac.getBean("sessionFactory");
System.out.println("-------> " + sessionFactory);
}
// 测试事务管理
@Test
public void testTransaction() {
Test
Service testService = (TestService) ac.getBean("testService");
testService.addUsers();
}
}