Announcement Announcement Module
No announcement yet.
ref bean vs. ref local Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • ref bean vs. ref local

    I've spent too much time on an issue with an import in my application context. I imported an applicationContext.xml in my applicationContext.xml file. Now I wanted to refer to the bean I declared in the imported file. I did: <ref local="beanname"/> the bean could not be found. I had to use <ref bean="beanname"/>. This issue was difficult to find because I simply tought that an included file should be referred to as a "local". Don't you agree?

    kind regards,

  • #2
    I believe the problem(?) is that "local" is an XML entity, whereas "<import>" is a Spring specific element which simply imports all beans defined in the other file into the current one.

    If "<import" was an XML entity that effectively did nothing more than replace the "<import" element with the contents of the referenced file, then sure, what you are proposing is correct, the entities in the included file would be local. Unfortunately it doesn't work this way.

    As it is, in terms of pure XML, they are two seperate files and are certainly not local to each other.

    Note: If you *did* want to include another *well-formed* xml document, you apparantely can :

    To be honest, at first I thought "<include" was a native XML instruction as well

    I am more than happy to be corrected


    • #3
      Thanks for your clearing this up yatesco, it makes sence to me now.


      • #4
        Hey, no problem.

        It was either this, or work (only kidding Chris (employer))