YAMLException:无法在类com.xxx.model.RuleEntities上找到属性'INC-0001'

时间:2018-11-27 02:05:59

标签: java yaml snakeyaml

我的Yaml文件如下:

INC-0001 :
    title : through_risk_trial_15
    action :
        - through_risk_trial
    post_action : loan
    trigger :
      -
        type : datetime
        compare : gt
        value : 15
        unit: day

INC-0002 :
    title : through_risk_trial_30
    action :
      - through_risk_trial
    post_action : loan
    trigger :
      -
        type : datetime
        compare : gt
        value : 30
        unit: day

和RuleEntities类

public class RuleEntities {
    private List<RuleEntity> ruleEntityList;

    public List<RuleEntity> getRuleEntityList() {
        return ruleEntityList;
    }

    public void setRuleEntityList(List<RuleEntity> ruleEntityList) {
        this.ruleEntityList = ruleEntityList;
    }

}

当我尝试加载yaml文件时:

RuleEntities ruleEntities = yaml.loadAs(input, RuleEntities.class);  

它引发了YAMLException:无法在类com.xxx.model.RuleEntities上找到属性'INC-0001'。 RuleEntity定义正确,但是无法加载主键“ INC-0001”,“ INC-0002”,我该如何定义要映射到主键的Object?

0 个答案:

没有答案