播放 2.6 注入 JPAApi 错误"No Persistence provider for EntityManager named defaultPersistenceUnit"



我在玩 2.6.15 应用程序中使用 Ebean。但是我没有在ebean中找到"getSingleResult"函数。我正在尝试使用JPAApi。当控制器尝试注入 JPAApi 时,我收到错误No Persistence provider for EntityManager named defaultPersistenceUnit

控制器。公共控制器.java

public class PublicController extends Controller {
@Inject
public PublicController(JPAApi apaApi) {}
}

build.sbt

lazy val server = (project in file("."))
.enablePlugins(BuildInfoPlugin, PlayJava, PlayEbean)
.settings(
libraryDependencies += guice,
libraryDependencies ++= Seq(
...
javaJpa,
"org.hibernate" % "hibernate-entitymanager" % "5.3.1.Final"
),
fork in run := true
)

/conf/META-INF/persistence.xml

<persistence 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"
version="2.1">
<persistence-unit name="defaultPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<non-jta-data-source>DefaultDS</non-jta-data-source>
<properties>
...
</properties>
</persistence-unit>
</persistence>

应用程序.conf

db {
default {
driver = com.mysql.jdbc.Driver
jndiName = DefaultDS
url = "***"
username = "***"
password = "***"
hikaricp {
minimumIdle = ${fixedConnectionPool}
maximumPoolSize = ${fixedConnectionPool}
}
}
}
jpa.default = defaultPersistenceUnit

我已经检查了所有内容,但我无法理解我做错了什么。请帮忙。谢谢!

它已解决。 是模型链接的问题,不正确 一对多和多对一链接

相关内容

最新更新