0
我知道這個問題以前已經問過,但我仍然無法讓JPA與我的項目一起工作。 我收到PersistenceException找不到提供程序。 我在我的src/main/resources/META-INF文件夾中有persistence.xml,我使用m2進行構建,但是持久性文件沒有移動到構建目錄。JPA 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="test" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.entities.User</class>
<class>com.entities.Group</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/BandwidthX"/>
<property name="javax.persistence.jdbc.password" value="password"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.user" value="root"/>
</properties>
</persistence-unit>
,我試圖用這個代碼堅持:
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("test");
EntityManager em = emf.createEntityManager();
對不起,沒有說清楚,但它在META-INF文件夾 – benehsv
啊,好的。使事情不太清楚。你能列出你執行的maven命令並檢查生成的.war文件的內容嗎? – kostja