Announcement Announcement Module
Collapse
No announcement yet.
Simple BeanFactory Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Simple BeanFactory

    I tried testing Spring BeanFactory like this:

    Code:
    import org.springframework.core.io.*;
    
    public class Foo {
    	ClassPathResource res=new ClassPathResource("beans.xml");
    	
    	FooBean fooBean;
    	
    	System.out.println(fooBean.getName());
    	
    }
    beans.xml
    Code:
    <beans>
      
      <bean id="fooBean" class="FooBean">
        <property name="name"><value>Joshua</value></property>
      </bean>
    
    </beans>
    Both files are located on the same directory. But nothing came out. I'm using eclipse for the IDE. What do I need to do in order to test the BeanFactory since the manual isn't comprehensive enough.

    Thnx

  • #2
    Change:
    Code:
    FooBean fooBean;
    to:
    Code:
    FooBean fooBean = res.getBean&#40;"fooBean"&#41;;

    Comment

    Working...
    X