javax.persistence.PersistenceException: No Persistence provider for EntityManager named userPU

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/inforstack/article/details/45967023
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named userPU
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:69)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)

at com.test.usermanage.test.ClientEntity.main(ClientEntity.java:13)

今天写个jpa的Demo,创建实体管理器工厂时候一直报错。上百度找了找,
有的说hibernate-EntityManager.jar 没添加,
有的说少了jpa的提供者,需要加上<provider>org.hibernate.ejb.HibernatePersistence</provider>
还有的说jar版本不对,等......


解决方式在resource文件夹下添加META-INF文件,然后把persistence.xml文件直接丢里面去,在获取实体管理器工厂,

javax.persistence.PersistenceException: No Persistence provider for EntityManager named userPU

上一篇:【实操】实例启动模板


下一篇:php api数据响应类封装