Play Framework ebean配置

时间:2012-07-02 14:46:50

标签: playframework playframework-2.0

当我尝试将一个简单的项目保存到我的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.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.*"

2 个答案:

答案 0 :(得分:3)

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

ebean.datasource.factory=jndi

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

答案 1 :(得分:0)

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

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

我还没有 local.conf 文件。