Spring in Action, 4th Edition: Covers Spring 4 (2015)

Preface

The best keeps getting better. More than a dozen years ago, Spring entered the Java development scene with the ambitious goal of simplifying enterprise Java development. It challenged the heavyweight programming models of the time with a simpler and lighter programming model based on plain old Java objects.

Now, several years and many releases later, we see that Spring has had a tremendous impact on enterprise application development. It has become a de facto standard framework for countless Java projects and has had an impact on the evolution of some of the specifications and frameworks that it originally set out to replace. It’d be hard to deny that the current Enterprise JavaBeans (EJB) specification may have turned out very differently had Spring not challenged earlier versions of the EJB spec.

But Spring itself continues to evolve and improve upon itself, always seeking to make the difficult development tasks simpler and empower Java developers with innovative features. Where Spring had first set out to challenge the status quo, Spring now has leapt ahead and is paving trails in Java application development.

Therefore, it’s time for an updated edition of this book to expose the current state of Spring. There’s so much that has happened in the past few years since the previous edition of this book; it’d be impossible to cover everything in a single edition. Nevertheless, I still tried to pack this fourth edition of Spring in Action with as much as I could. Here are just a few of the exciting new things that have been added in this edition:

·        An emphasis on Java-based Spring configuration with Java configuration options available for almost every area of Spring development

·        Conditional configuration and profiles that make runtime decisions regarding what Spring configuration should be used or ignored

·        Several enhancements and improvements to Spring MVC, especially with regard to creating REST services

·        Using Thymeleaf with Spring web applications as an alternative to JSP

·        Enabling Spring Security with Java-based configuration

·        Using Spring Data to automatically generate repository implementations at runtime for JPA, MongoDB, and Neo4j

·        Spring’s new declarative caching support

·        Asynchronous web messaging with WebSocket and STOMP

·        Spring Boot, a game-changing new approach to working with Spring

If you’re a seasoned Spring veteran, you’ll find that these new elements will become valuable additions to your Spring toolkit. On the other hand, if you’re new to Spring, you’ve picked a good time to learn Spring, and this book will help you get started.

This is, indeed, an exciting time to be working with Spring. It’s been a blast to develop with Spring and write about it during the past 12 years. I can’t wait to see what Spring does next!

Acknowledgments

Before this book goes to press, before it is bound, before it is boxed, before it is shipped, and before you get your hands on it, there are many other hands that have touched it along the way. Even if you have an eBook copy that didn’t go through that process, there were numerous hands on the bits and bytes that you downloaded—hands that edited it, reviewed it, typeset it, and proofread it. If it weren’t for all of those hands, this book wouldn’t exist.

First, a big thank you to everyone at Manning for working hard, for their patience when the writing wasn’t moving as fast as it should have, and for prodding me along to get it done: Marjan Bace, Michael Stephens, Cynthia Kane, Andy Carroll, Benjamin Berg, Alyson Brener, Dottie Marisco, Mary Piergies, Janet Vail, and many others behind the scenes.

Getting feedback early and often is just as critical when writing a book as it is when developing software. While the pages of this book were still in a very rough form, there were several great reviewers who took the time to read the drafts and provide feedback that helped shape the final product. Thanks to the following: Bob Casazza, Chaoho Hsieh, Christophe Martini, Gregor Zurowski, James Wright, Jeelani Basha, Jens Richter, Jonathan Thoms, Josh Hart, Karen Christenson, Mario Arias, Michael Roberts, Paul Balogh, and Ricardo da Silva Lima. And special thanks to John Ryan for his thorough technical review of the manuscript shortly before it went into production.

Of course, I want to thank my beautiful wife for enduring yet another writing project and for her encouragement along the way. I love you more than you could possibly ever know.

To Maisy and Madi, the most awesome little girls in the world, thank you again for your hugs, laughs, and unusual insights into what should go into the book.

To my colleagues on the Spring team, what can I say? You guys ROCK! I’m humbled and grateful for being a part of the organization that drives Spring forward. I never cease to be amazed at the never-ending awesomeness that you crank out.

And many thanks to everyone I encounter as I travel the country speaking at user groups and No Fluff/Just Stuff conferences.

Finally, thank you to the Phoenicians. You (and Epcot fans) know what you did.

About this Book

The Spring Framework was created with a very specific goal in mind—to make developing Java EE applications easier. Along the same lines, Spring in Action, Fourth Edition was written to make learning how to use Spring easier. My goal is not to give you a blow-by-blow listing of Spring APIs. Instead, I hope to present the Spring Framework in a way that is most relevant to a Java EE developer by providing practical code examples from real-world experiences. Since Spring is a modular framework, this book was written in the same way. I recognize that not all developers have the same needs. Some may want to learn the Spring Framework from the ground up, while others may want to pick and choose different topics and go at their own pace. That way, the book can act as a tool for learning Spring for the first time as well as a guide and reference for those wanting to dig deeper into specific features.

Spring in Action, Fourth Edition is for all Java developers, but enterprise Java developers will find it particularly useful. While I will guide you along gently through code examples that build in complexity throughout each chapter, the true power of Spring lies in its ability to make enterprise applications easier to develop. Therefore, enterprise developers will most fully appreciate the examples presented in this book. Because a vast portion of Spring is devoted to providing enterprise services, many parallels can be drawn between Spring and EJB.