Annotation Interface TestConfiguration
@Target(TYPE)
@Retention(RUNTIME)
@Documented
@Configuration
@TestComponent
public @interface TestConfiguration
@Configuration that can be used to define additional beans or
customizations for a test. Unlike regular @Configuration classes the use of
@TestConfiguration does not prevent auto-detection of
@SpringBootConfiguration.- Since:
- 1.4.0
- Author:
- Phillip Webb
- See Also:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanSpecify whether@Beanmethods should get proxied in order to enforce bean lifecycle behavior, e.g.Explicitly specify the name of the Spring bean definition associated with this Configuration class.
-
Element Details
-
value
Explicitly specify the name of the Spring bean definition associated with this Configuration class. SeeConfiguration.value()for details.- Returns:
- the specified bean name, if any
- Default:
- ""
-
proxyBeanMethods
@AliasFor(annotation=org.springframework.context.annotation.Configuration.class) boolean proxyBeanMethodsSpecify whether@Beanmethods should get proxied in order to enforce bean lifecycle behavior, e.g. to return shared singleton bean instances even in case of direct@Beanmethod calls in user code. This feature requires method interception, implemented through a runtime-generated CGLIB subclass which comes with limitations such as the configuration class and its methods not being allowed to declarefinal.The default is
true, allowing for 'inter-bean references' within the configuration class as well as for external calls to this configuration's@Beanmethods, e.g. from another configuration class. If this is not needed since each of this particular configuration's@Beanmethods is self-contained and designed as a plain factory method for container use, switch this flag tofalsein order to avoid CGLIB subclass processing.Turning off bean method interception effectively processes
@Beanmethods individually like when declared on non-@Configurationclasses, a.k.a. "@Bean Lite Mode" (see@Bean's javadoc). It is therefore behaviorally equivalent to removing the@Configurationstereotype.- Returns:
- whether to proxy
@Beanmethods - Since:
- 2.2.1
- Default:
- true
-