Announcement Announcement Module
No announcement yet.
Eclipse and Spring Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Eclipse and Spring

    I am a very newbie to both Eclipse and Spring. I have installed Eclipse 3.2.2 and the SpringIDE for eclipse. I think the set up is fine (I see Spring showing up in Project Properties, I see a small 's' on top of some of my files in eclipse - these are the files which are referred to in my config.xml (bean configuration files for spring?)

    Question: I am doing a very simple test case - An object that has another object (hence the dependency). I created the config.xml and referred to it in the Project Properties for Spring. My question is do we have to do any other specific thing for spring/eclipse to use this xml file? My xml file is very basic - I have an object customer that has two other objects (address and email.) my xml file is:

    <bean id="customer" class="Customer" depends-on="email, address" />

    <bean id="email" class="Email">
    <property name="fromEmail">
    <value>[email protected]</value>
    <property name="userId">
    <property name="password">
    <ref local="customer" />

    <bean id="address" class="Address">
    <property name="address1">
    <value>xyz drive</value>
    <property name="address2">
    <property name="city">
    <property name="state">
    <property name="zipCode">
    <ref local="customer" />


    I was under the understanding that the email and address properties would get set when the application was first started and hence customer would be able to automatically get those values but when I debug the test application (an instance of customer,) neither email nor address is set!

    Any ideas what I'm doing wrong or not understanding? Do we have to tell eclipse that it must use the config.xml?


  • #2
    First, are your configuration files referenced by the contextConfiguration in web.xml?

    Second, "depends-on" does not inject the values of email or address into Customer. Customer must have an Email field and an Address field, and the customer bean must property elements nested inside it referencing the email and address bean to set the values.

    For example, if customer has a field named "emailField", the the customer bean must have:
    <property name="emailField" ref="email" />

    I could be wrong, but I don't think you need <ref local="customer" /> in the email or address beans. I don't think that is how that element is used.

    See section 3.3 here: