使用Spring Annotations加载列表的映射

时间:2017-04-11 06:03:24

标签: java spring spring-annotations

我想从我的属性文件中加载它:

*.*.sherlock.reviewQuestionIds = "{
'SPARK_SELF_SERVE' : {
        'review-questions':[83021L, 82981L,83031L,83071L],
        'advertiserIndustry-question':[80351L],
        'productLine-question' : [83041L]
}
}";

使用以下方式加载数据:

@Value("#{'${sherlock.reviewQuestionIds}'.split(',')}")
private Map<CampaignType, Map<String, List<Long>>> questionsMapping;

请帮助解决此问题

堆栈跟踪是:[coral:launch] Exiting with throwable: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'providerServiceConfig': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.util.Map com.amazon.dadetcampaignprovider.spring.ProviderServiceConfig.questionsMapping; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.expression.spel.SpelParseException: EL1041E:(pos 8): After parsing a valid expression, there is still more data in the expression: 'SPARK_SELF_SERVE' [coral:launch] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'providerServiceConfig': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.util.Map com.amazon.dadetcampaignprovider.spring.ProviderServiceConfig.questionsMapping; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.expression.spel.SpelParseException: EL1041E:(pos 8): After parsing a valid expression, there is still more data in the expression: 'SPARK_SELF_SERVE' [coral:launch] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) [coral:launch] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1219) [coral:launch] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:551) [coral:launch] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) [coral:launch] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) [coral:launch] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [coral:launch] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) [coral:launch] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) [coral:launch] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:778) [coral:launch] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:843) [coral:launch] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) [coral:launch] at org.springframework.coral.CoralApplicationContext.refresh(CoralApplicationContext.java:203) [coral:launch] at com.amazon.coral.spring.Launcher.<init>(Launcher.java:119) [coral:launch] at com.amazon.coral.spring.Launcher.main(Launcher.java:72)

1 个答案:

答案 0 :(得分:0)

JSON格式无效

尝试更改为此

{
  'ProgramName': {
    'review-questions': [
      '81L',
      '82L',
      '831L',
      '301L'
    ],
    'Industry-question': [
      '351L'
    ],
    'product-question': [
      '41L'
    ]
  }
}