为嘛static块中try catch必须抛呢 public class TestHibernate {
private static final SessionFactory sessionFactory;
static{ try { sessionFactory = new Configuration().configure().buildSessionFactory(); } catch (HibernateException e) { // TODO Auto-generated catch block e.printStackTrace(); throw new HibernateException(e.getMessage()); }
} }
如果我不写throw new HibernateException(e.getMessage());eclipse编译private static final SessionFactory sessionFactory;这行就会报错,报错如下: Multiple markers at this line - The value of the field TestHibernate.sessionFactory is not used - The blank final field sessionFactory may not have been initialized
请高人指点下下
------解决方案-------------------- Multiple markers at this line - The value of the field TestHibernate.sessionFactory is not used - The blank final field sessionFactory may not have been initialized