批注接口 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
.- 从以下版本开始:
- 1.2.0
- 作者:
- Phillip Webb, Stephane Nicoll, Andy Wilkinson
-
可选元素概要
可选元素修饰符和类型可选元素说明Class<?>[]
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> TheBeanNameGenerator
class to be used for naming detected components within the Spring container.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.Class<?>[]
Type-safe alternative toscanBasePackages()
for specifying the packages to scan for annotated components.String[]
Base packages to scan for annotated components.
-
元素详细资料
-
exclude
Exclude specific auto-configuration classes such that they will never be applied.- 返回:
- the classes to exclude
- 默认值:
{}
-
excludeName
Exclude specific auto-configuration class names such that they will never be applied.- 返回:
- the class names to exclude
- 从以下版本开始:
- 1.3.0
- 默认值:
{}
-
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
@ComponentScan
only. It has no effect on@Entity
scanning or Spring DataRepository
scanning. For those you should add@EntityScan
and@Enable...Repositories
annotations.- 返回:
- base packages to scan
- 从以下版本开始:
- 1.3.0
- 默认值:
{}
-
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
@ComponentScan
only. It has no effect on@Entity
scanning or Spring DataRepository
scanning. For those you should add@EntityScan
and@Enable...Repositories
annotations.- 返回:
- base packages to scan
- 从以下版本开始:
- 1.3.0
- 默认值:
{}
-
nameGenerator
@AliasFor(annotation=org.springframework.context.annotation.ComponentScan.class, attribute="nameGenerator") Class<? extends BeanNameGenerator> nameGeneratorTheBeanNameGenerator
class to be used for naming detected components within the Spring container.The default value of the
BeanNameGenerator
interface itself indicates that the scanner used to process this@SpringBootApplication
annotation should use its inherited bean name generator, e.g. the defaultAnnotationBeanNameGenerator
or any custom instance supplied to the application context at bootstrap time.- 返回:
BeanNameGenerator
to use- 从以下版本开始:
- 2.3.0
- 另请参阅:
- 默认值:
org.springframework.beans.factory.support.BeanNameGenerator.class
-
proxyBeanMethods
@AliasFor(annotation=org.springframework.context.annotation.Configuration.class) boolean proxyBeanMethodsSpecify 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 declarefinal
.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 tofalse
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
- 默认值:
true
-