Results 1 to 2 of 2

Thread: Simple BeanFactory

  1. #1
    Join Date
    Nov 2004
    Location
    Jogjakarta, Indonesia
    Posts
    40

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

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

Similar Threads

  1. simple question
    By yukster in forum Security
    Replies: 6
    Last Post: Sep 19th, 2005, 07:58 AM
  2. BeanFactory, FactoryBean and &
    By cherrick in forum Architecture
    Replies: 1
    Last Post: Aug 23rd, 2005, 07:42 PM
  3. Replies: 1
    Last Post: Jul 1st, 2005, 02:48 AM
  4. JNDI BeanFactory lookup
    By edalquist in forum Container
    Replies: 4
    Last Post: Dec 16th, 2004, 02:18 PM
  5. Replies: 2
    Last Post: Aug 27th, 2004, 01:41 AM

Posting Permissions

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