Skip to content

Latest commit

 

History

History
28 lines (22 loc) · 1.67 KB

using-the-springbootapplication-annotation.adoc

File metadata and controls

28 lines (22 loc) · 1.67 KB

Using the @SpringBootApplication Annotation

Many Spring Boot developers like their apps to use auto-configuration, component scan and be able to define extra configuration on their "application class". A single @SpringBootApplication annotation can be used to enable those three features, that is:

link:{docs-java}/using/usingthespringbootapplicationannotation/springapplication/MyApplication.java[role=include]
Note
@SpringBootApplication also provides aliases to customize the attributes of @EnableAutoConfiguration and @ComponentScan.
Note

None of these features are mandatory and you may choose to replace this single annotation by any of the features that it enables. For instance, you may not want to use component scan or configuration properties scan in your application:

link:{docs-java}/using/usingthespringbootapplicationannotation/individualannotations/MyApplication.java[role=include]

In this example, Application is just like any other Spring Boot application except that @Component-annotated classes and @ConfigurationProperties-annotated classes are not detected automatically and the user-defined beans are imported explicitly (see @Import).