为什么这个.yml文件没有正确加载?

时间:2011-07-24 21:13:12

标签: playframework yaml

我一直在尝试使用以下代码加载以下.yml文件,它似乎无法正常工作。

我如何加载它:

@Test
public void testLoadData() {
    Fixtures.loadModels("initial-data.yml");
    Assert.assertTrue("Item2.count() should be greater than zero",Item2.count() > 0);
}

初​​始data.yml

# Test data
Item2(firstItem2):
    item2: test

Item2 .class

@Entity
public class Item2 extends Model {

    public String item2;

    public Item2(String item2) {
        this.item2 = item2;
    }

}

同样,这是一个非常简单的东西,至少我认为你会很简单......只是不知道为什么我得到一个AssertionFailedError。 yml文件已正确编码,我自己输入。另外,我测试了tutorial's files,他们的工作得很好。

提前致谢。

2 个答案:

答案 0 :(得分:0)

尝试

Fixtures.loadModels("initial-data.yml");
JPA.em().flush();
Assert.assertTrue("Item2.count() should be greater than zero",Item2.count() > 0);

这有帮助吗?

答案 1 :(得分:0)

试试'initial-data.yml'

的内容
Foo(firstItem2):
   item2: test

如果您没有收到错误,则使用错误的'initial-data.yml'。