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.
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.
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
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.
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 at 02:27 AM. Reason: typo
Thank you very much, I understand and will do.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.