简体   繁体   中英

Persistence.xml file of EntityManagerFactory in a jar file

Is there any way to put content of persistence.xml file to the source code that calling EntityManagerFactory? I tried building a project that contain persistence.xml but when I call the it from another project I always get this error:

[PersistenceException: No Persistence provider for EntityManager named cassandra_pu]

I also extract the jar file to check whether the xml file is included or not, it;s included in the WEB-INF folder. To me it's really weird because the persistence.xml is already in the jar file, why it keeps asking for the xml file?

The persistence.xml file must be in the root of your classpath. WEB-INF is not in the root of the class-path. If you want to put it in a .jar file, place it in WEB-INF/lib, if you want to have it outside a .jar file, place it in WEB-INF/classes. If you use JPA2 you no longer need that file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM