Page
1
Pro Spring 6 An In-Depth Guide to the Spring Framework — Sixth Edition — Iuliana Cosmina Rob Harrop Chris Schaefer Clarence Ho
Page
2
Pro Spring 6 An In-Depth Guide to the Spring Framework Sixth Edition Iuliana Cosmina Rob Harrop Chris Schaefer Clarence Ho
Page
3
Pro Spring 6: An In-Depth Guide to the Spring Framework ISBN-13 (pbk): 978-1-4842-8639-5 ISBN-13 (electronic): 978-1-4842-8640-1 https://doi.org/10.1007/978-1-4842-8640-1 Copyright © 2023 by Iuliana Cosmina, Rob Harrop, Chris Schaefer, and Clarence Ho 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. 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, Apress Media LLC: Welmoed Spahr Acquisitions Editor: Steve Anglin Development Editor: Laura Berendson Coordinating Editor: Mark Powers Copy Editor: Bill McManus Cover designed by eStudioCalamar Cover image by Anton Darius on Unsplash (https://unsplash.com) Distributed to the book trade worldwide by Apress Media, LLC, 1 New York Plaza, New York, NY 10004, U.S.A. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, 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 e-mail booktranslations@springernature.com; for reprint, paperback, or audio rights, please e-mail bookpermissions@springernature.com. Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and li- censes are also available for most titles. For more information, reference our Print and eBook Bulk Sales web page at https://www.apress.com/bulk-sales. Any source code or other supplementary material referenced by the authors in this book is available to readers on GitHub (https://github.com/Apress). For more detailed information, please visit https://www.apress.com/source-code. Printed on acid-free paper Iuliana Cosmina Kirkcaldy, UK Chris Schaefer Venice, FL, USA Rob Harrop Reddish, UK Clarence Ho Hong Kong, China
Page
4
I dedicate this book to my Evelyn Walker. Thank you for being the friend I never knew I needed. —Iuliana Cosmina
Page
5
(This page has no text content)
Page
6
(This page has no text content)
Page
7
(This page has no text content)
Page
8
(This page has no text content)
Page
9
(This page has no text content)
Page
10
(This page has no text content)
Page
11
(This page has no text content)
Page
12
(This page has no text content)
Page
13
(This page has no text content)
Page
14
(This page has no text content)
Page
15
(This page has no text content)
Page
16
(This page has no text content)
Page
17
(This page has no text content)
Page
18
About the Authors Iuliana Cosmina is a Spring Certified Web Developer and a Spring Certified Core Spring Professional. She is a Spring certified expert, as defined by Pivotal, the makers of Spring Framework, Spring Boot, and other tools. Iuliana has authored books with Apress on Core Spring certification and Spring Certified web development. She is a Lead Engineer at Cloudsoft, located in Edinburgh, Scotland, and is an active coder and software contributor on Apache Brooklyn, GitHub, StackOverflow, and more. Rob Harrop is a software consultant specializing in delivering high-performance, highly scalable enterprise applications. He is an experienced architect with a particular flair for understanding and solving complex design issues. With a thorough knowledge of both Java and .NET, Rob has successfully deployed projects across both platforms. He also has extensive experience across a variety of sectors, retail and government in particular. Rob is the author of five books, including the book you are currently reading, now at its sixth edition, a widely acclaimed, comprehensive resource on the Spring Framework. Chris Schaefer is a principle software developer for Spring projects at Pivotal, the makers of Spring Framework, Boot, and other Spring tools. Clarence Ho is the senior Java architect of a Hong Kong–based software consultancy firm, SkywideSoft Technology Limited. Having worked in the IT field for more than 20 years, Clarence has been the team leader of many in-house application development projects, as well as providing consultancy services on enterprise solutions to clients. xix
Page
19
About the Technical Reviewer 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 Springy Award 2013 Community Champion and Spring Champion. 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, including Pro Spring MVC with WebFlux (Apress, 2020), Pro Spring Boot 2 (Apress, 2019), Rapid Java Persistence and Microservices (Apress, 2019), Java Language Features (Apress, 2018), Spring Boot 2 Recipes (Apress, 2018), and Java APIs, Extensions and Libraries (Apress, 2018). You can read his detailed tutorials on Spring technologies and contact him through his blog at www. manueljordanelera.blogspot.com. You can follow Manuel on his Twitter account, @dr_pompeii. xxi
Page
20
Acknowledgments Writing this book was difficult. Spring has grown exponentially since the first edition of this book was written, and a small framework providing dependency injection for Java applications became a collection of projects designed to be used to develop a myriad of modern applications, from websites to mobile applications to mini applications run on Arduinos and microservices. This book has a long history; this is the sixth edition, after all. Rob Harrop and Jan Machacheck wrote a comprehensive Spring book named Pro Spring: From Professional to Expert, which was published in 2005; that was the first edition. Spring has changed dramatically over the past 18 years, and the book has evolved accordingly, so much so that there is little left of the original text. What you are reading right now is its sixth edition. In previous editions, a rotating cast of authors have taken the mantle and responsibility of making this book better and upgrading it to keep up with Spring Framework’s growth. I was brought on board for the fifth edition, to upgrade the material from Spring 4 to Spring 5, making this the second time I am involved in upgrading this book. However, I did not produce the sixth edition alone, so in this section I want to thank all the people involved: Steve Anglin for taking a gamble on me in 2014 and giving me a chance to become a technical author; Mark Powers for guiding me through the process of producing a book that is worth publishing; to my technical reviewer, Manual Jordan Elera, for making sure making sure the code in the book is good; all the grammar reviewers for making sure the text in the book is readable, understandable, and meaningful. A big thank you to the people who read the book, ran the code, and found errors and bugs that I and all those previously mentioned people missed: Rafal Nowicki, Carlos Perez, Affid Fedorov, and all the GitHub contributors. And the biggest thank you to my mentor, Achim Wagner, to my dearly departed friend, Evelyn Walker, and to my friends, Mihaela Filipiuc, Agustin Demouselle, and the Bogza-Vlad family, for always being there for me when I needed you. —Iuliana Cosmina xxiii