Results 1 to 2 of 2

Thread: A basic question on bean creation.

  1. #1
    Join Date
    Jul 2010
    Location
    India
    Posts
    19

    Unhappy A basic question on bean creation.

    I have one fundamental question on dependency injection.

    Assuming I have two beans definition

    Code:
    <bean id="SessionFactory"
    		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
    		scope="singleton" lazy-init="false">
    <bean/>
    Code:
    	<bean id="ObjectMain"
    		class="com.test.testSpring"
    		scope="prototype" autowire="constructor" lazy-init="false">
    		<constructor-arg index="0" value="SessionFactory" />
    	</bean>
    Now if this class testSpring object is created using the getBean call of the ClassPathXMLApplicationContext and if there are two constructor one with no parameters and one with SpringFactory as a parameter which one shall be called?

    I am asking this coz I have tried Autowiring the overloaded constructor with the SessionFactory object as
    HTML Code:
    required=true
    it still does not calls the overloaded constructor.

    Any help?

  2. #2
    Join Date
    Jul 2010
    Location
    India
    Posts
    19

    Smile

    I found the issue there. I was loading the wrong XML an had used annotation as well, so it was defaulting to annotation where in there was no definition of the injected bean.

    Thanks, anyways!

Tags for this Thread

Posting Permissions

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