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

  • Bean ID management.

    I have some problem of bean ID overlap-addition by many developers on one project.
    Is there any solution to avoid this issue?

    Thanks,
    Edward.

  • #2
    For larger projects I found it useful to separate contexts into several files and use bean ids with an according prefix to avoid name clashes.
    E.g. in a context file "security" I would have a "security.authenticationManager" bean.

    Hope that helps,
    Andreas

    Comment


    • #3
      Thanks for your help.

      Andreas, Thanks for your help. It's a helpful suggestion.

      BTW, I have additional question. If overlap-addition occur, Spring returns the bean which is defined at last without any exceptions. Isn't problematic? I had a vague awakening to spring intention, but i really wonder why it doesn't throw an exception as detail as possible.

      Any advice are welcome.

      Thanks,
      Edward.

      Comment


      • #4
        The "last bean definition wins" rule can be utilized to create default wirings which might be overriden (e.g. in testing scenarios) by loading extra context files. So there is really a use-case for that behavior.

        If you really do not want that behavior I think it can be changed. I vaguely remember a forum thread describing how to subclass an ApplicationContext class to achieve this. It wasn't too difficult though I do not remember the details. Maybe searching the forum and/or having a look at API documentation and source code does reveal the details.

        Regards,
        Andreas
        Last edited by Andreas Senft; Apr 16th, 2008, 02:27 AM. Reason: typo

        Comment


        • #5
          Thank you for your reply.

          The "last bean definition wins" rule can be utilized to create default wirings which might be overriden (e.g. in testing scenarios) by loading extra context files. So there is really a use-case for that behavior.

          If you really do not want that behavior I think it can be changed. I vaguely remember a forum thread describing how to subclass an ApplicationContext class to achieve this. It wasn't too difficult though I do not remember the details. Maybe searching the forum and/or having a look at API documentation and source code does reveal the details.
          Thank you very much, I understand and will do.

          Comment

          Working...
          X