如何配置persistence.xml提供程序标记 [英] How to configure persistence.xml provider tag

查看:58
本文介绍了如何配置persistence.xml提供程序标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我正在学习这些东西,我不太了解所有内容,而且遇到了问题,我不知道在persistence.xml的提供程序标记中写什么

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和pom.xml文件:

Here are my persistence.xml and pom.xml files:

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>

推荐答案

provider标记中,您需要包括特定于供应商的PersistenceProvider实现.

In provider tag you need to include vendor specific PersistenceProvider implementation.

请参考此讨论;您可能对此有所了解.

Please refer this discussion; you may get idea about this.

回答您的问题:-

如果您想使用JPA的Eclipselink实现,请使用如下所示的provider标记-

If you wanted to use Eclipselink implementation of JPA please use provider tag like below--

<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

OR

<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>

用于JPA的Hibernet实现.

for Hibernet implementation of JPA.

这篇关于如何配置persistence.xml提供程序标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆