开发者

jersey restful + grizzly server + hibernate

I can bring jersey + grizzly server up. But some problem occur during "SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory;" error says "SEVERE: service exception: org.hibernate.HibernateException: /hibernate.cfg.xml not fo开发者_如何学编程und

.. anyone know how to make hibernate can access hibernate.cfg.xml location.


Put it in the 'src/main/resources' directory of your project. Also, if you've specified "/hibernate.cfg.cml", try removing the slash so it reads "hibernate.cfg.xml"

If that doesn't work (no directory, classpath wrong, etc...) you can hardcode it to get it working.

File f = new File("/wherever/the/file/is/hibernate.cfg.xml"); 
sessions = new Configuration().configure(f).buildSessionFactory(); 

Then circle back later and repay your technical debt.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜