|
|
@@ -3,7 +3,7 @@
|
|
3
|
3
|
What you'll build
|
|
4
|
4
|
-----------------
|
|
5
|
5
|
|
|
6
|
|
-This guide provides an introduction to Spring Boot by building a simple web application. This doesn't demonstrate all of its features but will help you get started with the concepts Spring Boot has to offer.
|
|
|
6
|
+This guide provides an introduction to [Spring Boot][spring-boot] by building a simple web application. This doesn't demonstrate all of its features but will help you get started with the concepts Spring Boot has to offer.
|
|
7
|
7
|
|
|
8
|
8
|
What you'll need
|
|
9
|
9
|
----------------
|
|
|
@@ -195,13 +195,69 @@ There is also the `multipartConfigElement` you added. But along with it came a `
|
|
195
|
195
|
|
|
196
|
196
|
Other than that, everything else appears the same, as it should be. Most the beans listed above provide Spring MVC's production-grade features. Just swapping one aspect, the container, and adding upload support shouldn't cause a system wide ripple.
|
|
197
|
197
|
|
|
|
198
|
+Adding consumer-grade services
|
|
|
199
|
+------------------------------
|
|
|
200
|
+If you are building a web site for your business, there are probably some management services you are thinking about adding. Spring Boot provides several out of the box with it's [actuator module][spring-boot-actuator] like health, audits, beans, and more.
|
|
|
201
|
+
|
|
|
202
|
+Add this to your pom.xml:
|
|
|
203
|
+```xml
|
|
|
204
|
+ <dependency>
|
|
|
205
|
+ <groupId>org.springframework.boot</groupId>
|
|
|
206
|
+ <artifactId>spring-boot-starter-actuator</artifactId>
|
|
|
207
|
+ </dependency>
|
|
|
208
|
+```
|
|
|
209
|
+
|
|
|
210
|
+Then restart the app:
|
|
|
211
|
+
|
|
|
212
|
+```sh
|
|
|
213
|
+$ mvn package spring-boot:run
|
|
|
214
|
+```
|
|
|
215
|
+
|
|
|
216
|
+You will see a new set of RESTful end points added to the application. These are management services provided by Spring Boot.
|
|
|
217
|
+
|
|
|
218
|
+```sh
|
|
|
219
|
+2013-08-01 08:03:42.592 INFO 43851 --- [lication.main()] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.util.Map<java.lang.String, java.lang.Object> org.springframework.boot.ops.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
|
|
|
220
|
+2013-08-01 08:03:42.592 INFO 43851 --- [lication.main()] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[text/html],custom=[]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.ops.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)
|
|
|
221
|
+2013-08-01 08:03:42.844 INFO 43851 --- [lication.main()] o.s.b.o.e.mvc.EndpointHandlerMapping : Mapped URL path [/env] onto handler of type [class org.springframework.boot.ops.endpoint.EnvironmentEndpoint]
|
|
|
222
|
+2013-08-01 08:03:42.844 INFO 43851 --- [lication.main()] o.s.b.o.e.mvc.EndpointHandlerMapping : Mapped URL path [/health] onto handler of type [class org.springframework.boot.ops.endpoint.HealthEndpoint]
|
|
|
223
|
+2013-08-01 08:03:42.844 INFO 43851 --- [lication.main()] o.s.b.o.e.mvc.EndpointHandlerMapping : Mapped URL path [/beans] onto handler of type [class org.springframework.boot.ops.endpoint.BeansEndpoint]
|
|
|
224
|
+2013-08-01 08:03:42.844 INFO 43851 --- [lication.main()] o.s.b.o.e.mvc.EndpointHandlerMapping : Mapped URL path [/info] onto handler of type [class org.springframework.boot.ops.endpoint.InfoEndpoint]
|
|
|
225
|
+2013-08-01 08:03:42.845 INFO 43851 --- [lication.main()] o.s.b.o.e.mvc.EndpointHandlerMapping : Mapped URL path [/metrics] onto handler of type [class org.springframework.boot.ops.endpoint.MetricsEndpoint]
|
|
|
226
|
+2013-08-01 08:03:42.845 INFO 43851 --- [lication.main()] o.s.b.o.e.mvc.EndpointHandlerMapping : Mapped URL path [/trace] onto handler of type [class org.springframework.boot.ops.endpoint.TraceEndpoint]
|
|
|
227
|
+2013-08-01 08:03:42.845 INFO 43851 --- [lication.main()] o.s.b.o.e.mvc.EndpointHandlerMapping : Mapped URL path [/dump] onto handler of type [class org.springframework.boot.ops.endpoint.DumpEndpoint]
|
|
|
228
|
+2013-08-01 08:03:42.845 INFO 43851 --- [lication.main()] o.s.b.o.e.mvc.EndpointHandlerMapping : Mapped URL path [/shutdown] onto handler of type [class org.springframework.boot.ops.endpoint.ShutdownEndpoint]
|
|
|
229
|
+```
|
|
|
230
|
+
|
|
|
231
|
+They include:
|
|
|
232
|
+- Errors
|
|
|
233
|
+- [Environment](http://localhost:8080/env)
|
|
|
234
|
+- [Health](http://localhost:8080/health)
|
|
|
235
|
+- [Beans](http://localhost:8080/beans)
|
|
|
236
|
+- [Info](http://localhost:8080/info)
|
|
|
237
|
+- [Metrics](http://localhost:8080/metrics)
|
|
|
238
|
+- [Trace](http://localhost:8080/trace)
|
|
|
239
|
+- [Dump](http://localhost:8080/dump)
|
|
|
240
|
+- Shutdown
|
|
|
241
|
+
|
|
|
242
|
+You can invoke shutdown through curl.
|
|
|
243
|
+
|
|
|
244
|
+```sh
|
|
|
245
|
+$ curl -X POST localhost:8080/shutdown
|
|
|
246
|
+```
|
|
|
247
|
+
|
|
|
248
|
+The response shows that shutdown through REST is currently disabled:
|
|
|
249
|
+```sh
|
|
|
250
|
+{"message":"Shutdown not enabled, sorry."}
|
|
|
251
|
+```
|
|
|
252
|
+
|
|
|
253
|
+For more details about each of these REST points, you'll have to dig into the [Spring Boot][spring-boot] project itself.
|
|
|
254
|
+
|
|
198
|
255
|
That is not all
|
|
199
|
256
|
---------------
|
|
200
|
|
-That last example showed how Spring Boot makes it easy to wire beans you may not be aware you need. But Spring Boot does more than that. It supports not only traditional WAR file deployments, but also makes it easy to put together executable JARs thanks to Spring Boot's loader module. The various guides demonstrate this dual support through the `spring-boot-maven-plugin`.
|
|
|
257
|
+That last example showed how Spring Boot makes it easy to wire beans you may not be aware you need. And it showed how to turn on convenient management services.
|
|
201
|
258
|
|
|
202
|
|
-Spring Boot provides more than a quick way to wire beans. Spring Boot's [actuator module](https://github.com/SpringSource/spring-boot/blob/master/spring-boot-actuator/README.md) adds common needed business components like health, metrics, audits, and other features.
|
|
|
259
|
+But Spring Boot does more than that. It supports not only traditional WAR file deployments, but also makes it easy to put together executable JARs thanks to Spring Boot's loader module. The various guides demonstrate this dual support through the `spring-boot-maven-plugin`. On top of that, Spring Boot also have Groovy support, allowing you to build web apps with as little as a single file:
|
|
203
|
260
|
|
|
204
|
|
-Spring Boot also have Groovy support, allowing you to dynamically build web apps like this:
|
|
205
|
261
|
```groovy
|
|
206
|
262
|
@Controller
|
|
207
|
263
|
class ThisWillActuallyRun {
|
|
|
@@ -214,7 +270,7 @@ class ThisWillActuallyRun {
|
|
214
|
270
|
|
|
215
|
271
|
}
|
|
216
|
272
|
```
|
|
217
|
|
-Spring Boot automatically laces the code with key annotations and Groovy Grapes to pull down needed libraries to make the app run. With Spring Boot's CLI tool, all you need do is:
|
|
|
273
|
+Spring Boot dynamically adds key annotations toy our code and leverages [Groovy Grapes](http://groovy.codehaus.org/Grape) to pull down needed libraries to make the app run. With Spring Boot's CLI tool, all you need do is:
|
|
218
|
274
|
|
|
219
|
275
|
```sh
|
|
220
|
276
|
$ spring run app.groovy
|
|
|
@@ -224,6 +280,9 @@ Hello World!
|
|
224
|
280
|
|
|
225
|
281
|
Congratulations!
|
|
226
|
282
|
----------------
|
|
227
|
|
-Spring Boot is powerful, but frankly too big to fit into a single guide. This is just a sampling.
|
|
|
283
|
+Spring Boot is powerful, but frankly too big to fit into a single guide. This is just a sampling of how much it can ramp up your development pace, letting you focus on business features and not worry about infrastructure.
|
|
228
|
284
|
|
|
229
|
285
|
As you read more of this site's getting started guides, you will see it used all over the place. It might not be obvious at first, because Spring Boot is so good at adding the things you need without getting in your way. But after using it for a bit, you may wonder how you lived without it.
|
|
|
286
|
+
|
|
|
287
|
+[spring-boot]: https://github.com/SpringSource/spring-boot
|
|
|
288
|
+[spring-boot-actuator]: https://github.com/SpringSource/spring-boot/blob/master/spring-boot-actuator/README.md
|