Pro Spring Boot 2 (eBook)
XVII, 511 Seiten
Apress (Verlag)
978-1-4842-3676-5 (ISBN)
Quickly and productively develop complex Spring applications and microservices out of the box, with minimal concern over things like configurations. This revised book will show you how to fully leverage the Spring Boot 2 technology and how to apply it to create enterprise ready applications that just work. It will also cover what's been added to the new Spring Boot 2 release, including Spring Framework 5 features like WebFlux, Security, Actuator and the new way to expose Metrics through Micrometer framework, and more.
This book is your authoritative hands-on practical guide for increasing your enterprise Java and cloud application productivity while decreasing development time. It's a no nonsense guide with case studies of increasing complexity throughout the book. The author, a senior solutions architect and Principal Technical instructor with Pivotal, the company behind the Spring Framework, shares his experience, insights and first-hand knowledge about how Spring Boot technology works and best practices.
Pro Spring Boot 2 is an essential book for your Spring learning and reference library.
What You Will Learn
- Configure and use Spring Boot
- Use non-functional requirements with Spring Boot Actuator
- Carry out web development with Spring Boot
- Persistence with JDBC, JPA and NoSQL Databases
- Messaging with JMS, RabbitMQ and WebSockets
- Test and deploy with Spring Boot
- A quick look at the Spring Cloud projects
- Microservices and deployment to the Cloud
- Extend Spring Boot by creating your own Spring Boot Starter and @Enable feature
Quickly and productively develop complex Spring applications and microservices out of the box, with minimal concern over things like configurations. This revised book will show you how to fully leverage the Spring Boot 2 technology and how to apply it to create enterprise ready applications that just work. It will also cover what's been added to the new Spring Boot 2 release, including Spring Framework 5 features like WebFlux, Security, Actuator and the new way to expose Metrics through Micrometer framework, and more.This book is your authoritative hands-on practical guide for increasing your enterprise Java and cloud application productivity while decreasing development time. It's a no nonsense guide with case studies of increasing complexity throughout the book. The author, a senior solutions architect and Principal Technical instructor with Pivotal, the company behind the Spring Framework, shares his experience, insights and first-hand knowledge about how Spring Boottechnology works and best practices.Pro Spring Boot 2 is an essential book for your Spring learning and reference library.What You Will LearnConfigure and use Spring Boot Use non-functional requirements with Spring Boot ActuatorCarry out web development with Spring BootPersistence with JDBC, JPA and NoSQL DatabasesMessaging with JMS, RabbitMQ and WebSocketsTest and deploy with Spring BootA quick look at the Spring Cloud projectsMicroservices and deployment to the CloudExtend Spring Boot by creating your own Spring Boot Starter and @Enable featureWho This Book Is ForExperienced Spring and Java developers seeking increased productivity gains and decreased complexity and development time in their applications and software services.
Felipe Gutierrez is a Senior Platform Architect at Pivotal, the creators of Spring Boot and Spring Framework, where he serves as a senior consultant with the Spring team. He has over 20 years of IT experience, during which time he developed programs for companies in multiple vertical industries, such as government, retail, healthcare, education, and banking. He also develops in Groovy, RabbitMQ, and other technologies. Previously he has consulted for companies such as Nokia, Apple, Redbox, and Qualcomm, among others. He received his bachelors and master’s degree in computer science from Instituto Tecnologico y de Estudios Superiores de Monterrey Campus Ciudad de Mexico.
Table of Contents 5
About the Author 13
About the Technical Reviewer 14
Acknowledgments 15
Chapter 1: Spring Framework 5 16
A Little History 16
Design Principles and Patterns 17
Spring Framework 5 18
A Simple Spring Web Application 19
Using Maven for Creating a Project 19
Adding Dependencies 20
Spring Web Configuration 24
Classes 32
Running the App 38
Using Java Config 41
Summary 45
Chapter 2: Introduction to Spring Boot 46
Spring Boot 46
Spring Boot to the Rescue 48
Spring Boot CLI 49
Spring Boot Application Model 51
My First Spring Boot Application 52
Why Spring Boot? 57
Spring Boot Features 58
Summary 59
Chapter 3: Spring Boot Internals and Features 60
Auto-Configuration 60
Disable a Specific Auto-Configuration 63
@EnableAutoConfiguration and @Enable< Technology>
Spring Boot Features 69
SpringApplication Class 72
Custom Banner 73
SpringApplicationBuilder 78
Application Arguments 81
Accessing Arguments with an Executable JAR 83
ApplicationRunner and CommandLineRunner 83
Application Configuration 86
Configuration Properties Examples 88
Command-Line Arguments 89
Relaxed Binding 92
Changing Location and Name 93
Profile Based 94
Custom Properties Prefix 96
Summary 100
Chapter 4: Web Applications with Spring Boot 101
Spring MVC 101
Spring Boot MVC Auto-Configuration 102
Spring Boot Web: ToDo App 104
ToDo App 105
Domain Model: ToDo 107
Fluent API: ToDoBuilder 108
Repository: CommonRepository< T>
Repository: ToDoRepository 110
Validation: ToDoValidationError 111
Validation: ToDoValidationErrorBuilder 113
Controller: ToDoController 113
Running: ToDo App 118
Testing: ToDo App 119
Spring Boot Web: Overriding Defaults 124
Server Overriding 124
JSON Date Format 126
Content-Type: JSON/XML 126
Spring MVC: Overriding Defaults 128
Using a Different Application Container 128
Using Jetty Server 129
Spring Boot Web: Client 129
ToDo Client App 130
Domain Model: ToDo 131
Error Handler: ToDoErrorHandler 132
Custom Properties: ToDoRestClientProperties 133
Client: ToDoRestClient 134
Running and Testing the Client 137
Summary 138
Chapter 5: Data Access with Spring Boot 140
SQL Databases 140
Spring Data 141
Spring JDBC 142
JDBC with Spring Boot 143
ToDo App with JDBC 144
Repository: ToDoRepository 146
Database Initialization: schema.sql 149
Running and Testing: ToDo App 149
H2 Console 150
Spring Data JPA 152
Spring Data JPA with Spring Boot 153
ToDo App with Spring Data JPA 154
Repository: ToDoRepository 155
Domain Model: ToDo 156
Controller: ToDoController 159
Spring Boot JPA Properties 161
Running and Testing: ToDo App 162
Spring Data REST 163
Spring Data REST with Spring Boot 163
ToDo App with Spring Data JPA and Spring Data REST 164
Running: ToDo App 165
Testing: ToDo App 167
Testing with HAL Browser: ToDo App 169
No SQL Databases 171
Spring Data MongoDB 171
Spring Data MongoDB with Spring Boot 172
MongoDB Installation 172
MongoDB Embedded 173
ToDo App with Spring Data MongoDB 174
Domain Model: ToDo 176
Running and Testing: ToDo App 177
ToDo App with Spring Data MongoDB REST 178
Spring Data Redis 178
Spring Data Redis with Spring Boot 179
ToDo App with Spring Data Redis 179
Domain Model: ToDo 181
Running and Testing: ToDo App 182
More Data Features with Spring Boot 183
Multiple Data Sources 183
Summary 184
Chapter 6: WebFlux and Reactive Data with Spring Boot 185
Reactive Systems 185
The Reactive Manifesto 185
Project Reactor 187
ToDo App with Reactor 187
Mono< T>
Flux< T>
WebFlux 196
WebClient 198
WebFlux and Spring Boot Auto-configuration 199
Using WebFlux with Spring Boot 200
ToDo App with WebFlux 200
Using Annotated Controllers 203
Using Functional Endpoints 205
Reactive Data 208
MongoDB Reactive Streams 208
ToDo App with Reactive Data 208
Summary 218
Chapter 7: Testing with Spring Boot 219
Spring Testing Framework 219
Spring Boot Testing Framework 221
Testing Web Endpoints 222
Mocking Beans 223
Spring Boot Testing Slices 224
@JsonTest 224
@WebMvcTest 225
@WebFluxTest 226
@DataJpaTest 226
@JdbcTest 227
@DataMongoTest 228
@RestClientTest 229
Summary 230
Chapter 8: Security with Spring Boot 231
Spring Security 231
Security with Spring Boot 232
ToDo App with Basic Security 232
Overriding Simple Security 239
Overriding the Default Login Page 241
Custom Login Page 244
Using Security with JDBC 252
Directory App with JDBC Security 253
Using the Directory App within the ToDo App 262
WebFlux Security 269
ToDo App with OAuth2 269
Creating the ToDo App in GitHub 273
Summary 280
Chapter 9: Messaging with Spring Boot 281
What Is Messaging? 281
JMS with Spring Boot 282
ToDo App with JMS 282
ToDo Producer 284
ToDo Consumer 285
Configuring the ToDo App 286
Running the ToDo App 292
Using JMS Pub/Sub 293
Remote ActiveMQ 294
RabbitMQ with Spring Boot 294
Installing RabbitMQ 295
RabbitMQ/AMQP: Exchanges, Bindings, and Queues 295
ToDo App with RabbitMQ 297
ToDo Producer 298
ToDo Consumer 300
Configuring the ToDo App 301
Running the ToDo App 304
Remote RabbitMQ 309
Redis Messaging with Spring Boot 310
Installing Redis 310
ToDo App with Redis 310
ToDo Producer 312
ToDo Consumer 313
Configuring the ToDo App 314
Running the ToDo App 316
Remote Redis 318
WebSockets with Spring Boot 319
ToDo App with WebSockets 319
ToDo Producer 322
Configuring the ToDo App 324
ToDo Web Client 326
Running the ToDo App 328
Summary 330
Chapter 10: Spring Boot Actuator 331
Spring Boot Actuator 331
ToDo App with Actuator 332
/actuator 337
/actuator/conditions 338
/actuator/beans 339
/actuator/configprops 340
/actuator/threaddump 341
/actuator/env 342
/actuator/health 343
/actuator/info 345
/actuator/loggers 345
/actuator/loggers/{name} 346
/actuator/metrics 346
/actuator/mappings 348
/actuator/shutdown 349
/actuator/httptrace 351
Changing the Endpoint ID 352
Actuator CORS Support 353
Changing the Management Endpoints Path 353
Securing Endpoints 354
Configuring Endpoints 354
Implementing Custom Actuator Endpoints 355
ToDo App with Custom Actuator Endpoints 355
Spring Boot Actuator Health 365
ToDo App with Custom HealthIndicator 370
Spring Boot Actuator Metrics 375
ToDo App with Micrometer: Prometheus and Grafana 375
Prerequisites: Using Docker 378
docker-compose.yml 379
Running the ToDo App Metrics 381
General Stats for Spring Boot with Grafana 390
Summary 393
Chapter 11: Spring Integration and Spring Cloud Stream with Spring Boot 394
Spring Integration Primer 395
Programming Spring Integration 397
ToDo App with Spring Integration 397
Using XML 403
Using Annotations 406
Using JavaConfig 408
ToDo with File Integration 409
Spring Cloud Stream 416
Spring Cloud 416
Spring Cloud Stream 418
Spring Cloud Stream Concepts 418
Spring Cloud Stream Programming 420
ToDo App with Spring Cloud Stream 423
Source 425
Processor 432
Sink 439
Microservices 440
ToDo App: A Complete Flow 440
Spring Cloud Stream App Starters 441
Summary 442
Chapter 12: Spring Boot in the Cloud 443
The Cloud and Cloud-Native Architecture 443
Twelve-Factor Applications 444
Microservices 446
Preparing the ToDo App as a Microservice 447
Pivotal Cloud Foundry 448
PAS: Pivotal Application Service 449
PAS Features 450
Using PWS/PAS 451
Cloud Foundry CLI: Command-Line Interface 454
Log in to PWS/PAS Using the CLI Tool 454
Deploying the ToDo App into PAS 455
Creating Services 458
Cleaning Up 463
Summary 464
Chapter 13: Extending Spring Boot 465
Creating a spring-boot-starter 465
todo-client-spring-boot-starter 467
todo-client-spring-boot-autoconfigure 469
spring.factories 472
auto-configuration 472
Helper Classes 474
Creating an @Enable* Feature 477
ToDo REST API Service 481
Installing and Testing 484
Task Project 484
Running the Task App 487
Summary 489
Appendix A: Spring Boot CLI 490
Spring Boot CLI 490
The run Command 492
The test Command 494
The grab Command 497
The jar Command 498
The war Command 500
The install Command 501
The uninstall Command 502
The init Command 503
init Examples 505
An Alternative to the init Command 507
The shell Command 507
The help Command 508
Summary 509
Index 510
Erscheint lt. Verlag | 12.12.2018 |
---|---|
Zusatzinfo | XVII, 511 p. 117 illus. |
Verlagsort | Berkeley |
Sprache | englisch |
Themenwelt | Mathematik / Informatik ► Informatik ► Programmiersprachen / -werkzeuge |
Schlagworte | Applications • Boot • Cloud • Code • dell • Enterprise • Java • microframework • Microservices • Open Source • Pivotal • Software • Spring • Spring Boot • Spring Framework |
ISBN-10 | 1-4842-3676-9 / 1484236769 |
ISBN-13 | 978-1-4842-3676-5 / 9781484236765 |
Informationen gemäß Produktsicherheitsverordnung (GPSR) | |
Haben Sie eine Frage zum Produkt? |
Größe: 12,2 MB
DRM: Digitales Wasserzeichen
Dieses eBook enthält ein digitales Wasserzeichen und ist damit für Sie personalisiert. Bei einer missbräuchlichen Weitergabe des eBooks an Dritte ist eine Rückverfolgung an die Quelle möglich.
Dateiformat: PDF (Portable Document Format)
Mit einem festen Seitenlayout eignet sich die PDF besonders für Fachbücher mit Spalten, Tabellen und Abbildungen. Eine PDF kann auf fast allen Geräten angezeigt werden, ist aber für kleine Displays (Smartphone, eReader) nur eingeschränkt geeignet.
Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen dafür einen PDF-Viewer - z.B. den Adobe Reader oder Adobe Digital Editions.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen dafür einen PDF-Viewer - z.B. die kostenlose Adobe Digital Editions-App.
Zusätzliches Feature: Online Lesen
Dieses eBook können Sie zusätzlich zum Download auch online im Webbrowser lesen.
Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.
aus dem Bereich