Executing a Java SE JPA standalone application throws the exception:
javax.persistence.PersistenceException: No Persistence provider for EntityManager named test
I have found several similar posts but I think that none of them applies to my case with EclipseLink, Java SE and no packaging into deployable files and hence no WEB-INF etc.
The /src/META-INF/persistence.xml is:
<persistence>
<persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>SomeEntity</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/somedbname"/>
<property name="javax.persistence.jdbc.user" value="foo"/>
<property name="javax.persistence.jdbc.password" value="bar"/>
</properties>
</persistence-unit>
</persistence>
The following jars are on the build path:
您必须将eclipselink jar添加到您的ClassPath中,以检查它是否已经存在:
System.out.println(System.getProperty("java.class.path"));
我必须在xmlns属性的persistence.xml中提供持久性名称空间
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
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.