我尝试使用JPA将我的scala代码连接到mysql,然后我继续回到这个错误:
scala> DataToStore.storeData(url)
javax.persistence.PersistenceException: No Persistence provider for EntityManager named healthcenters
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:89)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)
at healthcenterdataload.Model$.emf(Model.scala:11)
at healthcenterdataload.Model$.em(Model.scala:13)
at healthcenterdataload.DataToStore$.storeData(HealthCenter.scala:41)
... 38 elided
这是我的persistence.xml,位于src / META-INF:
<?xml version="1.0" encoding="UTF-8"?>
<persistence 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"
version="2.0">
<persistence-unit name="healthcenters">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>healthcenterdataload.DataToStoreClass</class>
<class>healthcenterdataload.HealthCenterData</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:8889/healthcenters"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.password" value="root"/>
</properties>
</persistence-unit>
</persistence>
这是我在build.sbt中的依赖项:
libraryDependencies ++= Seq(
"org.json4s" %% "json4s-native" % "3.5.1",
"org.json4s" %% "json4s-jackson" % "3.5.1",
"javax.persistence" % "persistence-api" % "1.0",
"mysql" % "mysql-connector-java" % "5.1.36",
"org.hibernate" % "hibernate-core" % "5.2.10.Final",
"org.hibernate" % "hibernate-entitymanager" % "5.2.10.Final"
我的数据库名称和持久性单元目前具有相同的名称,但更改它似乎没有任何帮助。
思考?这是我第一次像这样将项目连接在一起,所以这是一个学习过程! :)
谢谢!