4

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

"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()"

我的播放 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.*"
4

2 回答 2

3

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

ebean.datasource.factory=jndi

并且 datasource.default 作为 JNDI DataSource 名称。您还可以覆盖默认为 java:comp/env/jdbc/ 的 ebean.datasource.jndi.prefix。

于 2012-07-02T17:01:32.757 回答
0

当没有正确的.conf文件时,通常会发生这种情况。例如,我使用以下命令运行 play 框架:

~/play-2.1.2/play -Dconfig.file=conf/local.conf

而且我没有local.conf文件。

于 2013-07-29T08:14:42.913 回答