【问题标题】:Access alias properties in Ebean when loading initial test data in Play在 Play 中加载初始测试数据时访问 Ebean 中的别名属性
【发布时间】:2013-04-10 08:34:49
【问题描述】:

我正在为 Play 2.1 中的模型加载初始测试数据。

我想访问问题模型的字符串属性“问题”。 这是我的 initial-data.yml 文件:

- &q1 !!models.Question
    id: 001
    question: Sample question?

- &mem1 !!models.Member
    id: 001
    memberName: Test

!!models.SecurityQuestion
    member: *mem1
    question:  *q1.question
    answer: sample answer

但我得到的只是以下错误:

Test models.ModelsTest.fullTest failed: while scanning an alias; expected alphabetic or numeric character, but found .

如何访问别名的属性?

【问题讨论】:

    标签: yaml playframework-2.1 ebean


    【解决方案1】:

    这个呢:

        questions: 
    
                - !!models.Question
                    id: 001
                    question: Sample question?
    
    
        members: 
    
                - !!models.Member
                    id: 001
                    memberName: Test
    
    
        security:
    
                !!models.SecurityQuestion
                    member:   !!models.Member
                                    id: 001
                    question: !!models.Question
                                    id: 001
                    answer: sample answer
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-09
      • 1970-01-01
      • 1970-01-01
      • 2010-11-05
      相关资源
      最近更新 更多