Spring 4.1 @Qualifier doesnt'work

前端 未结 8 1099
隐瞒了意图╮
隐瞒了意图╮ 2020-12-18 06:11

I have classes, xml configuration file and error stack trace like this. I have no idea why @Qualifier doesn\'t work. I see on errors that he don\'t even do anything.

8条回答
  •  攒了一身酷
    2020-12-18 07:18

    @Qualifier is used to reference a bean by its name or id. Since it can't find an xml entry that has a name or id of 'small' it tries to match by type, of which it found two instances of Size.

    The following would work:

            
        
        
    
    

    Though it appears you would like to treat instances of Size as pre-configured beans. If that were the case you could declare instances of Dog in your xml file and refer to Size beans ... something like this:

      
         
         
      
    

提交回复
热议问题