import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import studentDAO.Student;
public class StudentTest {
private SessionFactory sessionFactory;
private org.hibernate.Session session;
private Transaction transaction;
@Before
public void init(){
Configuration config = new Configuration().configure();//config为配置对象
sessionFactory = config.buildSessionFactory();//创建会话工厂
session = sessionFactory.openSession();
transaction = session.beginTransaction();//事物
}
@After
public void destroy(){
transaction.commit();//提交事物
session.close();//关闭会话
sessionFactory.close();//关闭工厂
}
@Test
public void testSaveStudent(){
Student student = new Student(1, "张三", "男", new Date(), "喜马拉雅");
session.save(student);
}
}
我也是啊,求解,要疯了
我也出现这个问题,请问怎么解决的,求教!
是不是没有服务注册对象