diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/anchor-rewrite.properties b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/anchor-rewrite.properties index 1f55fe4ac2..c3d0c67df0 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/anchor-rewrite.properties +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/anchor-rewrite.properties @@ -1016,4 +1016,7 @@ dependency-versions.coordinates=appendix.dependency-versions.coordinates dependency-versions.properties=appendix.dependency-versions.properties # gh-30405 -web.servlet.spring-mvc.json=features.json.jackson.custom-serializers-and-deserializers \ No newline at end of file +web.servlet.spring-mvc.json=features.json.jackson.custom-serializers-and-deserializers + +# gh-32795 +getting-started.first-application.code.enable-auto-configuration=getting-started.first-application.code.spring-boot-application diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/getting-started/first-application.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/getting-started/first-application.adoc index 7aeb30ecde..edbd00ba0a 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/getting-started/first-application.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/getting-started/first-application.adoc @@ -62,7 +62,7 @@ Open your favorite text editor and add the following: ifeval::["{spring-boot-artifactory-repo}" != "release"] - + spring-snapshots @@ -160,10 +160,13 @@ See the {spring-framework-docs}/web.html#mvc[MVC section] in the Spring Referenc -[[getting-started.first-application.code.enable-auto-configuration]] -==== The @EnableAutoConfiguration Annotation -The second class-level annotation is `@EnableAutoConfiguration`. -This annotation tells Spring Boot to "`guess`" how you want to configure Spring, based on the jar dependencies that you have added. +[[getting-started.first-application.code.spring-boot-application]] +==== The @SpringBootApplication Annotation +The second class-level annotation is `@SpringBootApplication`. +This annotation is known as a _meta-annotation_, it combines `@SpringBootConfiguration`, `@EnableAutoConfiguration` and `@ComponentScan`. + +Of those, the annotation we're most interested in here is `@EnableAutoConfiguration`. +`@EnableAutoConfiguration` tells Spring Boot to "`guess`" how you want to configure Spring, based on the jar dependencies that you have added. Since `spring-boot-starter-web` added Tomcat and Spring MVC, the auto-configuration assumes that you are developing a web application and sets up Spring accordingly. .Starters and Auto-configuration diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/gettingstarted/firstapplication/code/MyApplication.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/gettingstarted/firstapplication/code/MyApplication.java index c05e4abf45..62cabe70a6 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/gettingstarted/firstapplication/code/MyApplication.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/gettingstarted/firstapplication/code/MyApplication.java @@ -17,12 +17,12 @@ package org.springframework.boot.docs.gettingstarted.firstapplication.code; import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController -@EnableAutoConfiguration +@SpringBootApplication public class MyApplication { @RequestMapping("/") diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/gettingstarted/firstapplication/code/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/gettingstarted/firstapplication/code/MyApplication.kt index 798f5d3b50..a4ca07d621 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/gettingstarted/firstapplication/code/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/gettingstarted/firstapplication/code/MyApplication.kt @@ -16,13 +16,13 @@ package org.springframework.boot.docs.gettingstarted.firstapplication.code -import org.springframework.boot.autoconfigure.EnableAutoConfiguration +import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController @RestController -@EnableAutoConfiguration +@SpringBootApplication class MyApplication { @RequestMapping("/")