Results 1 to 4 of 4

Thread: Creating multiple beans of same type

  1. #1

    Thumbs down Creating multiple beans of same type

    Hi, Iam new to Spring, and i have a requirement of instantiating the bean based on its type.

    Code:
    Configuration
    AnnotationDrivenConfig
    public class A  {
    
    Bean
        public Art<VoiceMail> getVoiceMailRepository() {        
            return new Apple() ;
        }
    
    Bean
        public Art<Text> getTextRepository() {        
            return new Text() ;
        }
    }
    
    And i get the bean in another class using the following code snippet.
    import org.springframework.beans.factory.annotation.Autowired;
    Autowired
        Art<Text> text;
    
    //But i can't instantiate two beans of same type Art.Please let me know the resolution.

  2. #2
    Join Date
    Apr 2007
    Posts
    307

    Default

    Take a look at the documentation for @Qualifier and @Resource.
    Chris Beams
    Spring Framework committer, VMware
    http://github.com/cbeams

  3. #3
    Join Date
    Feb 2009
    Posts
    3

    Default

    Hi,
    i have 3 daos PersonDAO, AddressDAO and CompanyDAO.
    PersonDAO has reference of AddressDAO.
    AddressDAO has reference of CompanyDAO.
    CompanyDAO has reference of PersonDAO .
    CompanyDAO has reference of AddressDAO .


    Please note that when i remove "CompanyDAO has reference of AddressDAO "
    the exception goes.

  4. #4
    Join Date
    Feb 2009
    Posts
    3

    Default

    sorry wrong place

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •