我在java中的JPA应用程序遇到了一个奇怪的问题。我正在尝试从 MySQL 数据库中读取数据并将其写入 ObjectDB 嵌入数据库,但是当我尝试打开 Persistence 单元时,我收到了以下消息:
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named itunes_puSQL
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:85)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at br.com.lagranzotto.itunes.parser.main.iTunesParser.read(iTunesParser.java:78)
at br.com.lagranzotto.itunes.parser.main.iTunesParser.main(iTunesParser.java:72)
我的 persistence.xml 如下:
<persistence-unit name="itunes_pu" transaction-type="RESOURCE_LOCAL">
<provider>com.objectdb.jpa.Provider</provider>
<class>br.com.lagranzotto.itunes.parser.model.Album</class>
<class>br.com.lagranzotto.itunes.parser.model.Artist</class>
<class>br.com.lagranzotto.itunes.parser.model.Cover</class>
<class>br.com.lagranzotto.itunes.parser.model.Track</class>
<properties>
<property name="javax.persistence.jdbc.url" value="objectdb:itunes.odb"/>
</properties>
</persistence-unit>
<persistence-unit name="itunes_puSQL" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>br.com.lagranzotto.itunes.parser.model.Album</class>
<class>br.com.lagranzotto.itunes.parser.model.Artist</class>
<class>br.com.lagranzotto.itunes.parser.model.Cover</class>
<class>br.com.lagranzotto.itunes.parser.model.Track</class>
<properties>
<property name="eclipselink.jdbc.password" value="**************"/>
<property name="eclipselink.jdbc.user" value="itunes"/>
<property name="eclipselink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="eclipselink.jdbc.url" value="jdbc:mysql://localhost:3306/itunes"/>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
<property name="eclipselink.logging.level" value="INFO"/>
</properties>
</persistence-unit>
</persistence>
每个应用程序不能有多个持久性单元?