Annotation Interface SpringBootApplication
configuration class that declares one or more
@Bean methods and also triggers auto-configuration and component scanning. This is a convenience
annotation that is equivalent to declaring @SpringBootConfiguration,
@EnableAutoConfiguration and @ComponentScan.- Since:
- 1.2.0
- Author:
- Phillip Webb, Stephane Nicoll, Andy Wilkinson
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionClass<?>[]Exclude specific auto-configuration classes such that they will never be applied.String[]Exclude specific auto-configuration class names such that they will never be applied.Class<? extends BeanNameGenerator>TheBeanNameGeneratorclass to be used for naming detected components within the Spring container.booleanSpecify whether@Beanmethods should get proxied in order to enforce bean lifecycle behavior, e.g.Class<?>[]Type-safe alternative toscanBasePackages()for specifying the packages to scan for annotated components.String[]Base packages to scan for annotated components.
-
Element Details
-
exclude
Exclude specific auto-configuration classes such that they will never be applied.Since this annotation is parsed by loading class bytecode, it is safe to specify classes here that may ultimately not be on the classpath, only if this annotation is directly on the affected component and not if this annotation is used as a composed, meta-annotation. In order to use this annotation as a meta-annotation, only use the
excludeName()attribute.- Returns:
- the classes to exclude
- Default:
- {}
-
excludeName
Exclude specific auto-configuration class names such that they will never be applied.- Returns:
- the class names to exclude
- Since:
- 1.3.0
- Default:
- {}
-
scanBasePackages
@AliasFor(annotation=org.springframework.context.annotation.ComponentScan.class, attribute="basePackages") String[] scanBasePackagesBase packages to scan for annotated components. UsescanBasePackageClasses()for a type-safe alternative to String-based package names.Note: this setting is an alias for
@ComponentScanonly. It has no effect on@Entityscanning or Spring DataRepositoryscanning. For those you should add@EntityScanand@Enable...Repositoriesannotations.- Returns:
- base packages to scan
- Since:
- 1.3.0
- Default:
- {}
-
scanBasePackageClasses
@AliasFor(annotation=org.springframework.context.annotation.ComponentScan.class, attribute="basePackageClasses") Class<?>[] scanBasePackageClassesType-safe alternative toscanBasePackages()for specifying the packages to scan for annotated components. The package of each class specified will be scanned.Consider creating a special no-op marker class or interface in each package that serves no purpose other than being referenced by this attribute.
Note: this setting is an alias for
@ComponentScanonly. It has no effect on@Entityscanning or Spring DataRepositoryscanning. For those you should add@EntityScanand@Enable...Repositoriesannotations.- Returns:
- base packages to scan
- Since:
- 1.3.0
- Default:
- {}
-
nameGenerator
@AliasFor(annotation=org.springframework.context.annotation.ComponentScan.class, attribute="nameGenerator") Class<? extends BeanNameGenerator> nameGeneratorTheBeanNameGeneratorclass to be used for naming detected components within the Spring container.The default value of the
BeanNameGeneratorinterface itself indicates that the scanner used to process this@SpringBootApplicationannotation should use its inherited bean name generator, e.g. the defaultAnnotationBeanNameGeneratoror any custom instance supplied to the application context at bootstrap time.- Returns:
BeanNameGeneratorto use- Since:
- 2.3.0
- See Also:
- Default:
- org.springframework.beans.factory.support.BeanNameGenerator.class
-
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
- Default:
- true
-