Annotation Interface Component


@Indexed @Retention(RUNTIME) @Target({TYPE,METHOD}) public @interface Component
This annotation indicates that an annotated element is a bean component in your application
作者:
TODAY 2018-07-2 22:46:39
  • 可选元素概要

    可选元素
    修饰符和类型
    可选元素
    说明
    boolean
    Is this bean a candidate for getting autowired into some other bean?
    The optional name of a method to call on the bean instance upon closing the application context, for example a close() method on a JDBC DataSource implementation, or a Hibernate SessionFactory object.
    The optional name of a method to call on the bean instance during initialization.
    The name of this bean, or if several names, a primary bean name plus aliases.
    Alias for name().
  • 元素详细资料

    • value

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

      Intended to be used when no other attributes are needed, for example: @Component("customBeanName").

      另请参阅:
      默认值:
      {}
    • name

      @AliasFor("value") String[] name
      The name of this bean, or if several names, a primary bean name plus aliases.

      If left unspecified, the name of the bean is the name of the annotated method. If specified, the method name is ignored.

      The bean name and aliases may also be configured via the value() attribute if no other attributes are declared.

      另请参阅:
      默认值:
      {}
    • initMethods

      String[] initMethods
      The optional name of a method to call on the bean instance during initialization. Not commonly used, given that the method may be called programmatically directly within the body of a Bean-annotated method.

      The default value is "", indicating no init method to be called.

      另请参阅:
      默认值:
      {}
    • destroyMethod

      String destroyMethod
      The optional name of a method to call on the bean instance upon closing the application context, for example a close() method on a JDBC DataSource implementation, or a Hibernate SessionFactory object. The method must have no arguments but may throw any exception.

      As a convenience to the user, the container will attempt to infer a destroy method against an object returned from the @Bean method. For example, given an @Bean method returning an Apache Commons DBCP BasicDataSource, the container will notice the close() method available on that object and automatically register it as the destroyMethod. This 'destroy method inference' is currently limited to detecting only public, no-arg methods named 'close' or 'shutdown'. The method may be declared at any level of the inheritance hierarchy and will be detected regardless of the return type of the @Bean method (i.e., detection occurs reflectively against the bean instance itself at creation time).

      To disable destroy method inference for a particular @Bean, specify an empty string as the value, e.g. @Bean(destroyMethod=""). Note that the DisposableBean callback interface will nevertheless get detected and the corresponding destroy method invoked: In other words, destroyMethod="" only affects custom close/shutdown methods and Closeable/AutoCloseable declared close methods.

      Note: Only invoked on beans whose lifecycle is under the full control of the factory, which is always the case for singletons but not guaranteed for any other scope.

      另请参阅:
      默认值:
      "(inferred)"
    • autowireCandidate

      boolean autowireCandidate
      Is this bean a candidate for getting autowired into some other bean?

      Default is true; set this to false for internal delegates that are not meant to get in the way of beans of the same type in other places.

      从以下版本开始:
      4.0
      默认值:
      true