从YML Spring Config文件中找不到匹配的编辑器或转换策略

时间:2019-05-16 10:08:22

标签: java spring spring-boot grails

我在引导我的grails应用程序加载配置时遇到以下错误:

  

字段'ciab.cc'中的字段错误   'funnel.questionsAffectResults':拒绝的值   [[{{name = residencyStatus},{name = householdMonthlyFixExp},   {name = householdNetIncome},{name = ees_eval},{name = bankRelationship},   {name = monthlyIncome,conversionToAnnual = 12}]];码   [typeMismatch.ciab.cc.funnel.questionsAffectResults,typeMismatch.funnel.questionsAffectResults,typeMismatch.questionsAffectResults,typeMismatch.java.util.List,typeMismatch];   论点   [org.springframework.context.support.DefaultMessageSourceResolvable:   码   [ciab.cc.funnel.questionsAffectResults,funnel.questionsAffectResults];   参数[];默认消息[funnel.questionsAffectResults]];   默认消息[无法转换类型的属性值   [java.util.ArrayList]设置为属性的必需类型[java.util.List]   'funnel.questionsAffectResults';嵌套异常为   java.lang.IllegalStateException:无法转换类型的值   [org.springframework.beans.factory.config.YamlProcessor $ StrictMapAppenderConstructor $ 1]   到所需的类型[com.cgg.ciab.config.CreditCard $ Funnel $ Question]   属性“ questionsAffectResults [0]”:没有匹配的编辑器或   找到转换策略]

@Component
@ConfigurationProperties(prefix="ciab.cc")
class CreditCard {

    Funnel funnel

    static class Funnel {

        List<Question> questionsAffectResults

        static class Question {
            String name
            Double conversionToAnnual
        }
    }
}

Yml配置:

ciab:
  cc:
    funnel:
      questionsAffectResults:
        - name: residencyStatus
        - name: householdMonthlyFixExp
        - name: householdNetIncome
        - name: ees_eval
        - name: bankRelationship
        - name: monthlyIncome
          conversionToAnnual: 12

这在使用外部配置服务器时效果很好,但是当在Grails应用程序内部进行配置时,它将引发该异常。这里有什么区别吗?

我正在使用Grails 3.0.11。

谢谢

0 个答案:

没有答案