close

Filter

loading table of contents...

Blueprint Developer Manual / Version 2201

Table Of Contents

4.1.3.4 Redundant Spring Imports

Due to the design of the Spring Framework and the CoreMedia CMS, it is necessary to declare many <import/> elements in Spring configuration files, often pointing to the same resource. This slows down the startup of the ApplicationContext.

Unfortunately, org.springframework.beans.factory.xml.XmlBeanDefinitionReader does not track imported XML files, so redundant <import/> elements will lead to Spring parsing the same XML files over and over again (in most cases, those XML files will contain more <import/> elements leading to even more parsing, ...) After moving to Servlet 3.0 resources, for each <import/>, the JAR file containing the XML file has to be unpacked. Also, every time that an XML file is completely parsed, Spring reads all Bean declarations, creates new org.springframework.beans.factory.config.BeanDefinition instances, overwriting any existing BeanDefinitions for the same bean ID.

This release introduces an optional Spring Environment property skip.redundant.spring.imports that is true by default. If set to true, the first <import/> element will be used and all following, duplicate <import/> elements pointing to the same resource will be ignored. The time saved depends on the number of duplicated <import/> elements.

Caution

Caution

Even though this setting is recommended, it may change which bean definitions are loaded. (As explained above, normally, bean definitions may be overwritten by subsequent imports, depending on how <import/> elements are used in a web application).

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.