|
|
|
|
128
|
include::complete/src/main/java/hello/Application.java[]
|
128
|
include::complete/src/main/java/hello/Application.java[]
|
129
|
----
|
129
|
----
|
130
|
|
130
|
|
131
|
-`@SpringBootApplication` is a convenience annotation that adds all of the following:
|
|
|
132
|
-
|
|
|
133
|
-- `@Configuration` tags the class as a source of bean definitions for the application context.
|
|
|
134
|
-- `@EnableAutoConfiguration` tells Spring Boot to start adding beans based on classpath settings, other beans, and various property settings.
|
|
|
135
|
-- Normally you would add `@EnableWebMvc` for a Spring MVC app, but Spring Boot adds it automatically when it sees **spring-webmvc** on the classpath. This flags the application as a web application and activates key behaviors such as setting up a `DispatcherServlet`.
|
|
|
136
|
-- `@ComponentScan` tells Spring to look for other components, configurations, and services in the `hello` package, allowing it to find the `GreetingController`.
|
|
|
137
|
-
|
|
|
138
|
-The `main()` method uses Spring Boot's `SpringApplication.run()` method to launch an application. Did you notice that there wasn't a single line of XML? No **web.xml** file either. This web application is 100% pure Java and you didn't have to deal with configuring any plumbing or infrastructure.
|
|
|
|
|
131
|
+include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/spring-boot-application.adoc[]
|
139
|
|
132
|
|
140
|
include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/build_an_executable_jar_subhead.adoc[]
|
133
|
include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/build_an_executable_jar_subhead.adoc[]
|
141
|
|
134
|
|