[英]How to configure persistence.xml provider tag
Hey I'm learning this stuff, I don't really understand all of it and I have a problem, I don't know what to write in provider tag in persistence.xml 嘿,我正在学习这些内容,我不太了解所有内容,而且遇到了问题,我不知道在persistence.xml中的提供程序标记中写什么
Here are my persistence.xml and pom.xml files: 这是我的persistence.xml和pom.xml文件:
pom.xml pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.jpa</groupId>
<artifactId>JPAProject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.36</version>
</dependency>
</dependencies>
<build>
<finalName>JPAProject</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
</plugin>
</plugins>
</build>
persistence.xml persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="Database" transaction-type="RESOURCE_LOCAL">
<class>models.Employee</class>
<provider>WHAT TO WRITE HERE ?</provider>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/jpa"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.password" value="root"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
</properties>
</persistence-unit>
In provider
tag you need to include vendor specific PersistenceProvider
implementation. 在provider
标签中,您需要包括供应商特定的PersistenceProvider
实现。
Please refer this discussion ; 请参考这个讨论 ; you may get idea about this. 您可能对此有所了解。
Answer to your question:- 回答您的问题:
If you wanted to use Eclipselink implementation of JPA please use provider
tag like below-- 如果您想使用JPA的Eclipselink实现,请使用以下provider
标签-
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
OR 要么
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
for Hibernet implementation of JPA. 用于JPA的Hibernet实现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.