2016 Bookmatter Pro Spring Boot PDF

Title 2016 Bookmatter Pro Spring Boot
Author Daniel Bastidas
Course Licenciatura en Educación artística
Institution Corporación Universitaria Minuto de Dios
Pages 17
File Size 187.7 KB
File Type PDF
Total Downloads 105
Total Views 185

Summary

Download 2016 Bookmatter Pro Spring Boot PDF


Description

Pro Spring Boot

Felipe Gutierrez

Pro Spring Boot Felipe Gutierrez Albuquerque New Mexico, USA ISBN-13 (pbk): 978-1-4842-1432-9 DOI 10.1007/978-1-4842-1431-2

ISBN-13 (electronic): 978-1-4842-1431-2

Library of Congress Control Number: 2016941344 Copyright © 2016 by Felipe Gutierrez This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Exempted from this legal reservation are brief excerpts in connection with reviews or scholarly analysis or material supplied specifically for the purpose of being entered and executed on a computer system, for exclusive use by the purchaser of the work. Duplication of this publication or parts thereof is permitted only under the provisions of the Copyright Law of the Publisher’s location, in its current version, and permission for use must always be obtained from Springer. Permissions for use may be obtained through RightsLink at the Copyright Clearance Center. Violations are liable to prosecution under the respective Copyright Law. Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. Managing Director: Welmoed Spahr Lead Editor: Steve Anglin Technical Reviewer: Manuel Jordan Elera Editorial Board: Steve Anglin, Pramila Balan, Louise Corrigan, Jonathan Gennick, Robert Hutchinson, Celestin Suresh John, Michelle Lowman, James Markham, Susan McDermott, Matthew Moodie, Douglas Pundick, Ben Renow-Clarke, Gwenan Spearing Coordinating Editor: Mark Powers Copy Editor: Kezia Endsley Compositor: SPi Global Indexer: SPi Global Artist: SPi Global Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, [email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please [email protected], or visit www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page atwww.apress.com/bulk-sales. Any source code or other supplementary materials referenced by the author in this text is available to readers at www.apress.com/9781484214329. For detailed information about how to locate your book’s source code, go to www.apress.com/source-code/. Readers can also access source code at SpringerLink in the Supplementary Material section for each chapter. Printed on acid-free paper

To my wife, Norma Castaneda.

Contents at a Glance About the Author ................................................................................................... xiii About the Technical Reviewer .................................................................................xv Acknowledgments .................................................................................................xvii ■Chapter 1: Introduction to Spring Boot.................................................................. 1 ■Chapter 2: Your First Spring Boot Application ....................................................... 9 ■Chapter 3: Spring Boot Auto-Configuration, Features, and More ........................ 43 ■Chapter 4: Spring Boot CLI .................................................................................. 73 ■Chapter 5: Spring with Spring Boot ..................................................................... 89 ■Chapter 6: Testing with Spring Boot .................................................................. 107 ■Chapter 7: Data Access with Spring Boot.......................................................... 121 ■Chapter 8: Web Development with Spring Boot ................................................. 149 ■Chapter 9: Security with Spring Boot ................................................................ 177 ■Chapter 10: Messaging with Spring Boot .......................................................... 211 ■Chapter 11: Spring Boot Actuator ..................................................................... 245 ■Chapter 12: Deploying Spring Boot ................................................................... 283 ■Chapter 13: Spring Boot in the Cloud ................................................................ 307 ■Chapter 14: Extending Spring Boot Apps .......................................................... 335 ■Appendix: Spring Boot 1.4.x .............................................................................. 357 Index ..................................................................................................................... 361

v

Contents About the Author ................................................................................................... xiii About the Technical Reviewer .................................................................................xv Acknowledgments .................................................................................................xvii ■Chapter 1: Introduction to Spring Boot.................................................................. 1 Spring Boot ....................................................................................................................... 1 Spring Applications ................................................................................................................................. 2 Spring Boot to the Rescue ...................................................................................................................... 3 Why Spring Boot? ................................................................................................................................... 6 Spring Boot Features .............................................................................................................................. 6

Summary .......................................................................................................................... 7 ■Chapter 2: Your First Spring Boot Application ....................................................... 9 Installing Spring Boot CLI ................................................................................................. 9 UNIX OSs: Linux, OS X, and Solaris ......................................................................................................... 9 Windows OS.......................................................................................................................................... 11

Spring Boot with Maven and Gradle ............................................................................... 13 Using Maven ......................................................................................................................................... 13 Using Gradle ......................................................................................................................................... 14

Spring Boot Using External Tools.................................................................................... 16 Spring Boot Using the Spring Initializr .................................................................................................. 16 Using the Spring Initializr with UNIX cURL ............................................................................................ 18 Spring Boot Using Spring Tool Suite (STS) ............................................................................................ 19

vii

■ CONTENTS

Your First Spring Boot Application .................................................................................. 24 Spring Boot Journal .............................................................................................................................. 24 How Spring Boot Works ........................................................................................................................ 39

Summary ........................................................................................................................ 41 ■Chapter 3: Spring Boot Auto-Configuration, Features, and More ........................ 43 Auto-Configuration ......................................................................................................... 43 Disabling a Specific Auto-Configuration ............................................................................................... 45

@EnableAutoConfiguration and @Enable Annotations............................ 47 Spring Boot Features...................................................................................................... 49 SpringApplication Class ........................................................................................................................ 51 SpringApplicationBuilder ...................................................................................................................... 56 Application Arguments ......................................................................................................................... 58 ApplicationRunner and CommandLineRunner ...................................................................................... 60

Application Configuration ............................................................................................... 62 Configuration Properties Examples ...................................................................................................... 63 Custom Properties Prefix ...................................................................................................................... 69

Summary ........................................................................................................................ 72 ■Chapter 4: Spring Boot CLI .................................................................................. 73 Spring Boot CLI ............................................................................................................... 73 The run Command ................................................................................................................................ 74 The test Command ............................................................................................................................... 76 The grab Command .............................................................................................................................. 78 The jar Command ................................................................................................................................. 79 The war Command ............................................................................................................................... 80 The install Command ............................................................................................................................ 81 The uninstall Command ........................................................................................................................ 81 The init Command ................................................................................................................................ 82 The shell Command .............................................................................................................................. 85 The help Command ............................................................................................................................... 86

Summary ........................................................................................................................ 87 viii

■ CONTENTS

■Chapter 5: Spring with Spring Boot ..................................................................... 89 Spring Web Applications................................................................................................. 89 J2EE Web Applications ......................................................................................................................... 89 Spring MVC Applications....................................................................................................................... 93 Spring Boot Web Applications............................................................................................................... 98

Using Spring with Spring Boot ..................................................................................... 101 XML with Spring Boot ......................................................................................................................... 101 Groovy Beans in Spring Boot .............................................................................................................. 102 Standalone Spring Apps vs. Spring Boot Apps .................................................................................. 103

Using Spring Technologies in Spring Boot .................................................................... 104 Summary ...................................................................................................................... 105 ■Chapter 6: Testing with Spring Boot .................................................................. 107 Testing Spring Boot ...................................................................................................... 107 Web Testing .................................................................................................................. 109 Summary ...................................................................................................................... 120 ■Chapter 7: Data Access with Spring Boot.......................................................... 121 SQL Databases ............................................................................................................. 121 Data Access Using the JDBC Template with Spring Boot ................................................................... 122 Data Access Using JPA with Spring Boot............................................................................................ 131

NoSQL Databases ......................................................................................................... 140 Summary ...................................................................................................................... 147 ■Chapter 8: Web Development with Spring Boot ................................................. 149 Spring MVC ................................................................................................................... 149 Spring Boot Web Applications ...................................................................................... 150 Playing with the HAL Browser ...................................................................................... 171 Summary ...................................................................................................................... 175

ix

■ CONTENTS

■Chapter 9: Security with Spring Boot ................................................................ 177 Simple Security for Spring Boot ................................................................................... 177 Security Using the application.properties File .................................................................................... 181 In-Memory Security ............................................................................................................................ 182 Security Using a Database.................................................................................................................. 183 Securing Resources ............................................................................................................................ 186

Spring Boot with OAuth2 .............................................................................................. 199 Summary ...................................................................................................................... 209 ■Chapter 10: Messaging with Spring Boot .......................................................... 211 What Is Messaging? ..................................................................................................... 211 JMS with Spring Boot ................................................................................................... 211 A Simpler JMS Consumer ................................................................................................................... 217 Connect to Remote JMS Server .......................................................................................................... 221

RabbitMQ with Spring Boot .......................................................................................... 221 Installing RabbitMQ ............................................................................................................................ 221 RabbitMQ/AMQP: Exchanges, Bindings, and Queues.......................................................................... 221 Remote RabbitMQ ............................................................................................................................... 231

Redis Messaging with Spring Boot .............................................................................. 231 Installing Redis ................................................................................................................................... 231 Remote Redis ..................................................................................................................................... 237

WebSockets with Spring Boot ...................................................................................... 237 Summary ...................................................................................................................... 244 ■Chapter 11: Spring Boot Actuator ..................................................................... 245 Spring Boot Actuator .................................................................................................... 245 /actuator ............................................................................................................................................. 248 /autoconfig ......................................................................................................................................... 249 /beans ................................................................................................................................................. 250 /configprops ....................................................................................................................................... 251 /docs ..............


Similar Free PDFs