spring autowiring with unique beans: Spring expected single matching bean but found 2

后端 未结 4 1086
滥情空心
滥情空心 2020-11-30 01:06

I am trying to autowire some beans (for dependency injection) using Spring for a webapp. One controller bean contains another bean which in turn holds a hashmap of another

4条回答
  •  隐瞒了意图╮
    2020-11-30 01:40

    For me it was case of having two beans implementing the same interface. One was a fake ban for the sake of unit test which was conflicting with original bean. If we use

    @component("suggestionServicefake")

    , it still references with suggestionService. So I removed @component and only used

    @Qualifier("suggestionServicefake")

    which solved the problem

提交回复
热议问题