Required Multiple beans of same type in Spring

后端 未结 3 554
忘掉有多难
忘掉有多难 2020-12-04 18:18

A request before you mark it as duplicate. I have gone through the forum and couldn\'t find the solution for the problem anywhere.

I am writing a code using Spring 3

3条回答
  •  被撕碎了的回忆
    2020-12-04 18:40

    You should qualify your autowired variable to say which one should be injected

    @Autowired
    @Qualifier("A1Unmarshaller")
    private Jaxb2Marshaller A1Unmarshaller;
    

    The default autowiring is by type, not by name, so when there is more than one bean of the same type, you have to use the @Qualifier annotation.

提交回复
热议问题