Package org.springframework.context.annotation

# Annotation Interface ImportResource

@Retention(RUNTIME) @Target(TYPE) @Documented public @interface 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 configuration. 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 `locations` or `value` attribute will be processed using a `GroovyBeanDefinitionReader` for resource locations ending in `".groovy"`; otherwise, an `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.

Since:
  3.0
Author:
  Chris Beams, Juergen Hoeller, Sam Brannen
See Also:
  - `Configuration`
  - `Import`

## Optional Element Summary

Optional Elements
Modifier and Type
Optional Element
Description
`String[]`
`locations`
Resource locations from which to import.
`Class<? extends org.springframework.beans.factory.support.BeanDefinitionReader>`
`reader`
`BeanDefinitionReader` implementation to use when processing resources specified via the `locations` or `value` attribute.
`String[]`
`value`
Alias for `locations()`.

## Element Details

### value

@AliasFor("locations") String[] value
Alias for `locations()`.

See Also:
  - `locations()`
  - `reader()`

Default:
  {}

### locations

@AliasFor("value") String[] locations
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.

Since:
  4.2
See Also:
  - `value()`
  - `reader()`

Default:
  {}

### reader

Class<? extends org.springframework.beans.factory.support.BeanDefinitionReader> reader
`BeanDefinitionReader` implementation to use when processing resources specified via the `locations` or `value` attribute.

The configured `BeanDefinitionReader` type must declare a constructor that accepts a single `BeanDefinitionRegistry` argument.

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

See Also:
  - `locations()`
  - `value()`

Default:
  org.springframework.beans.factory.support.BeanDefinitionReader.class