Spring Java config wraps injected map

前端 未结 1 1697
甜味超标
甜味超标 2021-01-15 12:28

I recently switched from using Spring\'s XML configuration to its Java configuration and am encountering a strange issue.

The XML configuration was:

         


        
1条回答
  •  感情败类
    2021-01-15 12:37

    There is an issue @Autowired-ing a Map even defining the bean name and since as-per the comments you can't use the suggested @Resource annotation there is an alternative by using the @Value annotation defining the bean name:

    @Bean
    public MyClass myBean(@Value("#{myMap}") final Map myMap) {
    //..
    }
    

    0 讨论(0)
提交回复
热议问题