Java 没有名为itmd4515PU的EntityManager的持久性提供程序
我是JPA的新手。 我不断地发现这个错误:Java 没有名为itmd4515PU的EntityManager的持久性提供程序,java,xml,maven,jpa,Java,Xml,Maven,Jpa,我是JPA的新手。 我不断地发现这个错误: No Persistence provider for EntityManager named 我尝试了其他帖子的一些建议。喜欢加 <provider>org.hibernate.ejb.HibernatePersistence</provider> org.hibernate.ejb.HibernatePersistence 在Persistence.xml中。加 <dependency>
No Persistence provider for EntityManager named
我尝试了其他帖子的一些建议。喜欢加
<provider>org.hibernate.ejb.HibernatePersistence</provider>
org.hibernate.ejb.HibernatePersistence
在Persistence.xml中。加
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
org.hibernate.javax.persistence
下面是我的持久性单元:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="itmd4515PU" transaction-type="JTA">
<provider>org.hibernate.HibernatePersistence</provider>
<jta-data-source>jdbc/itmd4515DS</jta-data-source>
<class>edu.iit.sat.itmd4515.jwang206.domain.Address</class>
<class>edu.iit.sat.itmd4515.jwang206.domain.CD_Store</class>
<class>edu.iit.sat.itmd4515.jwang206.domain.Item</class>
<class>edu.iit.sat.itmd4515.jwang206.domain.Supplier</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
</properties>
</persistence-unit>
</persistence>
org.hibernate.HibernatePersistence
jdbc/itmd4515DS
edu.iit.sat.itmd4515.jwang206.domain.Address
edu.iit.sat.itmd4515.jwang206.domain.CD_商店
edu.iit.sat.itmd4515.jwang206.domain.Item
edu.iit.sat.itmd4515.jwang206.domain.Supplier
真的
和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>edu.iit.sat.itmd4515.jwang206</groupId>
<artifactId>jwang206-fp</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>jwang206-fp</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.5</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.5.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.4.0.CR1</version>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.el</artifactId>
<version>2.2.6</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
<version>2.5.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.1.Final</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
4.0.0
edu.iit.sat.itmd4515.jwang206
请告知,非常感谢 您已经获得了由javax.persistence接口组成的API依赖项,但是您还需要一些具体的实现
将此依赖项添加到pom.xml(版本号由您决定):
org.hibernate
冬眠核心
5.2.7.最终版本
然后将持久性提供程序更改为:
<persistence-unit name="itmd4515PU" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
org.hibernate.jpa.HibernatePersistenceProvider
您已经获得了由javax.persistence接口组成的API依赖项,但您还需要一些具体的实现
将此依赖项添加到pom.xml(版本号由您决定):
org.hibernate
冬眠核心
5.2.7.最终版本
然后将持久性提供程序更改为:
<persistence-unit name="itmd4515PU" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
org.hibernate.jpa.HibernatePersistenceProvider
我仍然收到错误提示:线程“main”javax.persistence.PersistenceException中出现异常:添加新实现后无法找到持久性单元。请添加WAR文件内容的结构。。特别是META-INF所在的位置我很抱歉,但是添加WAR文件内容的结构是什么意思?persistence.xml必须位于/META-INF中,并且位于包的根目录下。是吗?测试成功了吗?我仍然会收到错误提示:线程“main”javax.persistence.PersistenceException中的异常:在添加新实现后无法定位持久性单元。添加WAR文件内容的结构。。特别是META-INF所在的位置我很抱歉,但是添加WAR文件内容的结构是什么意思?persistence.xml必须位于/META-INF中,并且位于包的根目录下。是吗?测试顺利吗?