gpt4 book ai didi

playframework - Play 框架 ebean 配置

转载 作者:行者123 更新时间:2023-12-01 02:33:52 42 4
gpt4 key购买 nike

当我尝试将一个简单的项目保存到我的 H2 db 时出现此错误:

"javax.persistence.PersistenceException: The default EbeanServer has not been defined ? This is normally set via the ebean.datasource.default property. Otherwise it should be registered programatically via registerServer()"

我的 Play application.conf 文件
 # Database configuration
# ~~~~~
# You can declare as many datasources as you want.
# By convention, the default datasource is named `efault
db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:mem:play"
db.default.jndiName=DefaultDS
db.default.user=sa
db.default.password=""

# JPA configuration
# ~~~~~
# You can declare as many Ebean servers as you want.
# By convention, the default server is named `default`
jpa.default=defaultPersistenceUnit
ebean.datasource.default=DefaultDS
ebean.default="models.*"

最佳答案

要使用 JNDI 数据源,您需要设置:

ebean.datasource.factory=jndi

和 datasource.default 作为 JNDI 数据源名称。您还可以覆盖默认为 java:comp/env/jdbc/的 ebean.datasource.jndi.prefix。

关于playframework - Play 框架 ebean 配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11295996/

42 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com