Announcement Announcement Module
Collapse

JavaConfig forum decommissioned in favor of Core Container

As described at

http://static.springsource.org/sprin...fig/README.TXT

key features of the Spring JavaConfig project have been migrated into the core Spring Framework as of version 3.0.

Please see the Spring 3.0 documentation on @Configuration and @Bean support:

http://static.springsource.org/sprin...tml#beans-java

For any questions related to @Configuration classes and @Bean methods in Spring 3.0, please post in the dedicated 'Core Container' forum at

http://forum.springsource.org/forumdisplay.php?f=26
See more
See less
Creating multiple beans of same type Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Take a look at the documentation for @Qualifier and @Resource.

    Comment


    • #3
      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.

      Comment


      • #4
        sorry wrong place

        Comment

        Working...
        X