简体   繁体   中英

Load Map of Lists using Spring Annotations

I want to load this from my properties file:

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

Loading the data using :

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

Please help on this

Stack trace is : [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) [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)

The JSON format is invalid

Try to change to this

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM