批注接口 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.
从以下版本开始:
1.4.0
作者:
Phillip Webb
另请参阅:
  • 可选元素概要

    可选元素
    修饰符和类型
    可选元素
    说明
    boolean
    Specify whether @Bean methods should get proxied in order to enforce bean lifecycle behavior, e.g. to return shared singleton bean instances even in case of direct @Bean method calls in user code.
    Explicitly specify the name of the Spring bean definition associated with this Configuration class.
  • 元素详细资料

    • value

      Explicitly specify the name of the Spring bean definition associated with this Configuration class. See Configuration.value() for details.
      返回:
      the specified bean name, if any
      默认值:
      ""
    • proxyBeanMethods

      Specify whether @Bean methods should get proxied in order to enforce bean lifecycle behavior, e.g. to return shared singleton bean instances even in case of direct @Bean method 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 declare final.

      The default is true, allowing for 'inter-bean references' within the configuration class as well as for external calls to this configuration's @Bean methods, e.g. from another configuration class. If this is not needed since each of this particular configuration's @Bean methods is self-contained and designed as a plain factory method for container use, switch this flag to false in order to avoid CGLIB subclass processing.

      Turning off bean method interception effectively processes @Bean methods individually like when declared on non-@Configuration classes, a.k.a. "@Bean Lite Mode" (see @Bean's javadoc). It is therefore behaviorally equivalent to removing the @Configuration stereotype.

      返回:
      whether to proxy @Bean methods
      从以下版本开始:
      2.2.1
      默认值:
      true