spring-framework / org.springframework.context.annotation / ImportResource

ImportResource

@Target([AnnotationTarget.CLASS, AnnotationTarget.FILE]) class ImportResource

Indicates one or more resources containing bean definitions to import.

Like Import, this annotation provides functionality similar to the <import/> element in Spring XML. It is typically used when designing Configuration classes to be bootstrapped by an AnnotationConfigApplicationContext, but where some XML functionality such as namespaces is still necessary.

By default, arguments to the #value attribute will be processed using a org.springframework.beans.factory.groovy.GroovyBeanDefinitionReader if ending in ".groovy"; otherwise, an org.springframework.beans.factory.xml.XmlBeanDefinitionReader will be used to parse Spring <beans/> XML files. Optionally, the #reader attribute may be declared, allowing the user to choose a custom BeanDefinitionReader implementation.

Author
Chris Beams

Author
Juergen Hoeller

Author
Sam Brannen

Since
3.0

See Also
ConfigurationImport

Constructors

<init>

ImportResource(vararg value: String, locations: Array<String>, reader: KClass<out BeanDefinitionReader>)

Indicates one or more resources containing bean definitions to import.

Like Import, this annotation provides functionality similar to the <import/> element in Spring XML. It is typically used when designing Configuration classes to be bootstrapped by an AnnotationConfigApplicationContext, but where some XML functionality such as namespaces is still necessary.

By default, arguments to the #value attribute will be processed using a org.springframework.beans.factory.groovy.GroovyBeanDefinitionReader if ending in ".groovy"; otherwise, an org.springframework.beans.factory.xml.XmlBeanDefinitionReader will be used to parse Spring <beans/> XML files. Optionally, the #reader attribute may be declared, allowing the user to choose a custom BeanDefinitionReader implementation.

Properties

locations

val locations: Array<String>

Resource locations from which to import.

Supports resource-loading prefixes such as classpath:, file:, etc.

Consult the Javadoc for #reader for details on how resources will be processed.

reader

val reader: KClass<out BeanDefinitionReader>

BeanDefinitionReader implementation to use when processing resources specified via the #value attribute.

By default, the reader will be adapted to the resource path specified: ".groovy" files will be processed with a org.springframework.beans.factory.groovy.GroovyBeanDefinitionReader; whereas, all other resources will be processed with an org.springframework.beans.factory.xml.XmlBeanDefinitionReader.

value

val value: Array<String>

Alias for #locations.