-
Notifications
You must be signed in to change notification settings - Fork 38.4k
Load files in <import resource=... />
only once [SPR-1142]
#5845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Sébastien Launay commented Because this issue is opened for many years I was thinking of proposing a solution because our spring configuration uses lots of XML files decomposed with imports and lots of AOP configuration :) and computing unused bean definitions is expensive at runtime. So here is a patch for loading application context resources only once against the trunk.
This feature is enabled by setting the bean property I do not know if this is interesting but I do not modified JavaConfig classes to reflect such behavior with Let me know if this approach is right or if I need to go in another direction. |
Tim Ducheyne commented Just a small remark about the patch: There is a problem with the hashcode and equals implementation of URL brgds, |
Felix Simmendinger commented This behaviour is espacially then problematic, because BPP are executed multiple times if they are declared as anonymous beans or defined via a namespace eg. <context:property-placeholder ... . For the latter it is impossible to define an id. Since there are special beans that can be defined only once eg. the multipartresolver this problem means you cannot hide the multipartresolver in a xml file hierarchy as it may be loaded twice. |
Dennis Homann commented This is a real pain and punishes people who modularize their application context in multiple smaller XML files. |
Keith Donald commented Can someone provide more info on why you would import the same file more than once? I'm curious what is trying to be accomplished where this comes up, as I've never encountered this myself in practice. |
Dale Wyttenbach commented It typically happens indirectly: |
Andy Schäfer commented Some additional thoughts to the comment of Dale Wyttenbach in answer to Keith Donald: In order to ensure, that C isn't loaded twice we import in the topmost application.spring.xml all configurations (A, B, C and D). So the import of C is done only there, nowhere else.
Maybe there are approaches better than the one I outlined (interested to hear of them), but this issue would be handy to solve the problem in a simple way:
|
Neha commented Since this issue had been logged around 9 years back and is still unresolved, I was just wondering if there is some major reason for it? |
Lucian Yao commented Please fix this issue. I was blamed by the peers by using the import in lower-level modules to save a lot of time in config and deploy. |
Bulk closing outdated, unresolved issues. Please, reopen if still relevant. |
<import resource=... />
only once [SPR-1142]
If you were following this issue, you may be interested in the following. |
Martin Zeltner opened SPR-1142 and commented
Example:
file1.xml:
<beans>
<import resource="classpath:common/common-config.xml"/>
...
</beans>
file2.xml:
<beans>
<import resource="classpath:common/common-config.xml"/>
...
</beans>
If I load now an application context which has "file1.xml" and "file2.xml" as config locations, the file "common-config.xml" will be loaded twice. I suggest to remember the url of already loaded config files.
Thanks,
Martin
Affects: 1.2.1
Attachments:
Issue Links:
67 votes, 52 watchers
The text was updated successfully, but these errors were encountered: