Procházet zdrojové kódy

Fine tune guide with details about spring-boot-actuator

Greg Turnquist před 13 roky
rodič
revize
1cb29f0d31
3 změnil soubory, kde provedl 134 přidání a 12 odebrání
  1. 65
    6
      README.ftl.md
  2. 65
    6
      README.md
  3. 4
    0
      complete/pom.xml

+ 65
- 6
README.ftl.md Zobrazit soubor

3
 What you'll build
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
 What you'll need
8
 What you'll need
9
 ----------------
9
 ----------------
195
 
195
 
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.
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
 That is not all
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
 ```groovy
261
 ```groovy
206
 @Controller
262
 @Controller
207
 class ThisWillActuallyRun {
263
 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
 ```sh
275
 ```sh
220
 $ spring run app.groovy
276
 $ spring run app.groovy
224
 
280
 
225
 Congratulations!
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
 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.
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

+ 65
- 6
README.md Zobrazit soubor

2
 What you'll build
2
 What you'll build
3
 -----------------
3
 -----------------
4
 
4
 
5
-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.
5
+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.
6
 
6
 
7
 What you'll need
7
 What you'll need
8
 ----------------
8
 ----------------
363
 
363
 
364
 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.
364
 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.
365
 
365
 
366
+Adding consumer-grade services
367
+------------------------------
368
+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.
369
+
370
+Add this to your pom.xml:
371
+```xml
372
+        <dependency>
373
+            <groupId>org.springframework.boot</groupId>
374
+            <artifactId>spring-boot-starter-actuator</artifactId>
375
+        </dependency>
376
+```
377
+
378
+Then restart the app:
379
+
380
+```sh
381
+$ mvn package spring-boot:run
382
+```
383
+
384
+You will see a new set of RESTful end points added to the application. These are management services provided by Spring Boot.
385
+
386
+```sh
387
+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)
388
+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)
389
+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]
390
+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]
391
+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]
392
+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]
393
+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]
394
+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]
395
+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]
396
+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]
397
+```
398
+
399
+They include:
400
+- Errors
401
+- [Environment](http://localhost:8080/env)
402
+- [Health](http://localhost:8080/health)
403
+- [Beans](http://localhost:8080/beans)
404
+- [Info](http://localhost:8080/info)
405
+- [Metrics](http://localhost:8080/metrics)
406
+- [Trace](http://localhost:8080/trace)
407
+- [Dump](http://localhost:8080/dump)
408
+- Shutdown
409
+
410
+You can invoke shutdown through curl.
411
+
412
+```sh
413
+$ curl -X POST localhost:8080/shutdown
414
+```
415
+
416
+The response shows that shutdown through REST is currently disabled:
417
+```sh
418
+{"message":"Shutdown not enabled, sorry."}
419
+```
420
+
421
+For more details about each of these REST points, you'll have to dig into the [Spring Boot][spring-boot] project itself.
422
+
366
 That is not all
423
 That is not all
367
 ---------------
424
 ---------------
368
-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`.
425
+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.
369
 
426
 
370
-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.
427
+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:
371
 
428
 
372
-Spring Boot also have Groovy support, allowing you to dynamically build web apps like this:
373
 ```groovy
429
 ```groovy
374
 @Controller
430
 @Controller
375
 class ThisWillActuallyRun {
431
 class ThisWillActuallyRun {
382
 
438
 
383
 }
439
 }
384
 ```
440
 ```
385
-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:
441
+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:
386
 
442
 
387
 ```sh
443
 ```sh
388
 $ spring run app.groovy
444
 $ spring run app.groovy
392
 
448
 
393
 Congratulations!
449
 Congratulations!
394
 ----------------
450
 ----------------
395
-Spring Boot is powerful, but frankly too big to fit into a single guide. This is just a sampling.
451
+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.
396
 
452
 
397
 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.
453
 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.
454
+
455
+[spring-boot]: https://github.com/SpringSource/spring-boot
456
+[spring-boot-actuator]: https://github.com/SpringSource/spring-boot/blob/master/spring-boot-actuator/README.md

+ 4
- 0
complete/pom.xml Zobrazit soubor

22
             <groupId>org.springframework.boot</groupId>
22
             <groupId>org.springframework.boot</groupId>
23
             <artifactId>spring-boot-starter-jetty</artifactId>
23
             <artifactId>spring-boot-starter-jetty</artifactId>
24
         </dependency>
24
         </dependency>
25
+        <dependency>
26
+            <groupId>org.springframework.boot</groupId>
27
+            <artifactId>spring-boot-starter-actuator</artifactId>
28
+        </dependency>
25
     </dependencies>
29
     </dependencies>
26
 
30
 
27
     <properties>
31
     <properties>