我正在努力运行我的第一个 Play! 2.1.x 应用程序,我总是收到此错误(这是由于运行 test
案例):
我已经阅读了官方手册,许多 SO 问题,甚至一些博客,但我仍然不明白为什么我一直在得到这个。
注意: 我在 test.conf
中指定了来自 this SO question 的 Build.scala
文件。
这是 test.conf
的内容:
include "application.conf"
application.version=${application.major}.${application.minor}.${application.revision}-TEST
db.default.driver=org.h2.Driver
db.default.jndiName=DefaultDS
db.default.url="jdbc:h2:mem:play;MODE=PostgreSQL;DB_CLOSE_DELAY=-1"
db.default.user=sa
db.default.password=""
ebean.default="models.*"
ebean.datasource.factory=jndi
ebean.datasource.default=DefaultDS
注意: 在 application.conf
中也指定了相同的键,但使用“prod”值。我错过了什么?
谢谢!
** 编辑 **
测试用例非常简单。我正在使用一个基类,从 this blog 按原样复制粘贴:
public class TestSomeModel extends BaseModelTest {
@Test
public void myModelCreate() {
SomeModel model = new SomeModel();
model.someStringAttribute = "some value";
assertThat(model.id).isNull();
model.save(); // <--- this is the line that gives the error
assertThat(model.id).isPositive();
}
}
......如果有人坚持要看模特类......@Entity
public class SomeModel extends Model {
@Id
public Long id;
public String someStringAttribute;
}
最佳答案
在模型前添加@Entity
@Entity
公共(public)类 SomeModel 扩展模型 {
关于java - Play 框架 2.1.x 和 EbeanServer,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18424659/