Felipe Gutierrez

Pro Spring Boot

Felipe Gutierrez

Albuquerque, New Mexico, USA

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.

ISBN 978-1-4842-1432-9

e-ISBN 978-1-4842-1431-2

DOI 10.1007/978-1-4842-1431-2

Library of Congress Control Number: 2016941344

© Felipe Gutierrez 2016

Pro Spring Boot

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

For information on translations, please e-mail [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 at www.apress.com/bulk-sales .

included in front matter

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.

Printed on acid-free paper

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, e-mail [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.

To my wife, Norma Castaneda.

Acknowledgments

I would like to express all my gratitude to the Apress team—to Steve Anglin for accepting my proposal; to Mark Powers for keeping me on track and for his patience with me; to Matthew Moodie and the rest of the Apress team involved in this project. Thanks to everybody for making this possible.

Thanks to my technical reviewer, Manuel Jordan, for all the details and effort in his reviews, and the entire Spring Boot team for creating this amazing technology.

Thanks to my parents, Rocio Cruz and Felipe Gutierrez, for all their love and support. Thanks to my brother Edgar Gerardo Gutierrez. Special thanks to my girls who keep me on track: Norma, Nayely my “Flaca,” and Ximena my “Gallito”. I love you girls!

—Felipe Gutierrez

Contents

  1. Chapter 1:​ Introduction to Spring Boot
    1. Spring Boot
      1. Spring Applications
      2. Spring Boot to the Rescue
      3. Why Spring Boot?​
      4. Spring Boot Features
    2. Summary
  2. Chapter 2:​ Your First Spring Boot Application
    1. Installing Spring Boot CLI
      1. UNIX OSs:​ Linux, OS X, and Solaris
      2. Windows OS
    2. Spring Boot with Maven and Gradle
      1. Using Maven
      2. Using Gradle
    3. Spring Boot Using External Tools
      1. Spring Boot Using the Spring Initializr
      2. Using the Spring Initializr with UNIX cURL
      3. Spring Boot Using Spring Tool Suite (STS)
    4. Your First Spring Boot Application
      1. Spring Boot Journal
      2. How Spring Boot Works
    5. Summary
  3. Chapter 3:​ Spring Boot Auto-Configuration, Features, and More
    1. Auto-Configuration
      1. Disabling a Specific Auto-Configuration
    2. @EnableAutoConfig​uration and @Enable<Technolog​y> Annotations
    3. Spring Boot Features
      1. SpringApplicatio​n Class
      2. SpringApplicatio​nBuilder
      3. Application Arguments
      4. ApplicationRunne​r and CommandLineRunne​r
    4. Application Configuration
      1. Configuration Properties Examples
      2. Custom Properties Prefix
    5. Summary
  4. Chapter 4:​ Spring Boot CLI
    1. Spring Boot CLI
      1. The run Command
      2. The test Command
      3. The grab Command
      4. The jar Command
      5. The war Command
      6. The install Command
      7. The uninstall Command
      8. The init Command
      9. The shell Command
      10. The help Command
    2. Summary
  5. Chapter 5:​ Spring with Spring Boot
    1. Spring Web Applications
      1. J2EE Web Applications
      2. Spring MVC Applications
      3. Spring Boot Web Applications
    2. Using Spring with Spring Boot
      1. XML with Spring Boot
      2. Groovy Beans in Spring Boot
      3. Standalone Spring Apps vs.​ Spring Boot Apps
    3. Using Spring Technologies in Spring Boot
    4. Summary
  6. Chapter 6:​ Testing with Spring Boot
    1. Testing Spring Boot
    2. Web Testing
    3. Summary
  7. Chapter 7:​ Data Access with Spring Boot
    1. SQL Databases
      1. Data Access Using the JDBC Template with Spring Boot
      2. Data Access Using JPA with Spring Boot
    2. NoSQL Databases
    3. Summary
  8. Chapter 8:​ Web Development with Spring Boot
    1. Spring MVC
    2. Spring Boot Web Applications
    3. Playing with the HAL Browser
    4. Summary
  9. Chapter 9:​ Security with Spring Boot
    1. Simple Security for Spring Boot
      1. Security Using the application.​properties File
      2. In-Memory Security
      3. Security Using a Database
      4. Securing Resources
    2. Spring Boot with OAuth2
    3. Summary
  10. Chapter 10:​ Messaging with Spring Boot
    1. What Is Messaging?​
    2. JMS with Spring Boot
      1. A Simpler JMS Consumer
      2. Connect to Remote JMS Server
    3. RabbitMQ with Spring Boot
      1. Installing RabbitMQ
      2. RabbitMQ/​AMQP:​ Exchanges, Bindings, and Queues
      3. Remote RabbitMQ
    4. Redis Messaging with Spring Boot
      1. Installing Redis
      2. Remote Redis
    5. WebSockets with Spring Boot
    6. Summary
  11. Chapter 11:​ Spring Boot Actuator
    1. Spring Boot Actuator
      1. /​actuator
      2. /​autoconfig
      3. /​beans
      4. /​configprops
      5. /​docs
      6. /​dump
      7. /​env
      8. /​flyway
      9. /​health
      10. /​info
      11. /​liquibase
      12. /​logfile
      13. /​metrics
      14. /​mappings
      15. /​shutdown
      16. /​trace
    2. Sensitive Endpoints
    3. Changing the Endpoint ID
    4. Actuator CORS Support
    5. Changing the Management Endpoints Path
    6. Using Spring Boot Actuator in a Non-Web Application
    7. Summary
  12. Chapter 12:​ Deploying Spring Boot
    1. Setting Up the Spring Boot Journal App
      1. Creating the SSL Self-Signed Keystore
    2. Testing SSL
    3. Creating Executable JARs
      1. The Java Way
      2. The Spring Boot Way
    4. Creating Executable and Deployable WARs
      1. Deploying to a Tomcat-Based Server
      2. Activating Profiles
    5. Creating Spring Boot Apps as a Service
      1. Spring Boot Apps as Windows Service
    6. Spring Boot with Docker
    7. Summary
  13. Chapter 13:​ Spring Boot in the Cloud
    1. The Cloud and Cloud-Native Architectures
    2. Twelve-Factor Applications
    3. Microservices
      1. Preparing the Spring Boot Journal App as Microservice
    4. Cloud Foundry
      1. Cloud Foundry
      2. Pivotal Cloud Foundry Features
      3. Cloud Foundry CLI - Command Line Interface
      4. Development Enviroment - PCFDev
    5. Pivotal Cloud Foundry
      1. Deploying to Pivotal Web Services
    6. Summary
  14. Chapter 14:​ Extending Spring Boot Apps
    1. Custom Spring Boot Module
      1. The spring-boot-journal Project
      2. The journal-spring-boot-starter Project
      3. The journal-spring-boot-autoconfigure Project
      4. Package and Install the Journal Project
      5. The spring-boot-calendar Project
    2. Custom Health Indicator
    3. Summary
  15. Appendix: Spring Boot 1.4.x
  16. Spring Boot 1.4.X Release Notes
  17. Upgrading from Spring Boot 1.3
  18. New and Noteworthy
  19. Index

About the Author and About the Technical Reviewer

About the Author

A340891_1_En_BookFrontmatter_Figb_HTML.jpg

Felipe Gutierrez is a solutions software architect, with bachelor’s and master’s degrees in computer science from Instituto Tecnologico y de Estudios Superiores de Monterrey Campus Ciudad de Mexico. Gutierrez has over 20 years of IT experience, during which time he developed programs for companies in multiple vertical industries, including government, retail, healthcare, education, and banking. He currently works as a principal technical instructor for Pivotal, specializing in Cloud Foundry, Spring Framework, Spring Cloud Native Applications, Groovy, and RabbitMQ, among other technologies. He has worked as a solutions architect for big companies like Nokia, Apple, Redbox, and Qualcomm, among others. He is also the author of the Apress title Introducing Spring Framework .

About the Technical Reviewer

A340891_1_En_BookFrontmatter_Figc_HTML.jpg

Manuel Jordan Elera is an autodidactic developer and researcher who enjoys learning new technologies for his own experiments and creating new integrations.

Manuel won the 2010 Springy Award—Community Champion and Spring Champion 2013. In his little free time, he reads the Bible and composes music on his guitar. Manuel is known as dr_pompeii . He has tech reviewed numerous books for Apress, including Pro Spring, 4th Edition (2014), Practical Spring LDAP (2013), Pro JPA 2, Second Edition (2013), and Pro Spring Security (2013).

Read his 13 detailed tutorials about many Spring technologies and contact him through his blog at http://www.manueljordanelera.blogspot.com or follow him on his Twitter account at @dr_pompeii .

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.81.33