How to use persistence.xml and hibernate.cfg.xml in JUnit tests via eclipse?
问题 I have been searching for an answer during quite a long time before coming here and ask this question. My problem is very simple : I cannot run any JUnit test when using the JPA Entity Manager API. It seems that my test is not reading the persistence.xml file. When I call new Configuration().configure().buildSessionFactory() , it works like a charm but an exception is thrown when calling Persistence.createEntityManagerFactory("myapp") is: javax.persistence.PersistenceException: No Persistence