Spring Boot in Action

所需积分/C币:9 2018-01-18 12:50:27 6.64MB PDF
20
收藏 收藏
举报

Spring Boot aims to simplify Spring development. As such, Spring Boot’s reach stretches to touch everything that Spring touches. It’d be impossible to write a book that covers every single way that Spring Boot can be used, as doing so would involve covering every single technology that Spring itself supports. Instead, Spring Boot in Action aims to distill Spring Boot into four main topics: auto-configuration, starter dependencies, the command-line interface, and the Actuator. Along the way, we’ll touch on a few Spring features as necessary, but the focus will be primarily on Spring Boot.
For online information and ordering of this and other Manning books, please visit www.manning.com.Thepublisheroffersdiscountsonthisbookwhenorderedinquantity For more information, please contact Special sales Department Manning publications co 20 Baldwin road POBoⅹ761 Shelter island. nY11964 Emailorders@manning.com 02016 by Manning Publications Co. All rights reserved No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and manning Publications was aware of a trademark claim, the designations have been printed in initial caps OI lI caps Recognizing the importance of preserving what has been written, it is Mannings policy to have the books we publish printed on acid-free paper and we exert our best efforts to that end Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine Manning Publications Co Development editor: Cynthia Kane 20 Baldwin Road Technical development editor: Robert casazza POBOⅹ761 ditor Andy carroll Shelter island. ny11964 Proofreader: Corbin Collins Technical proofreader John Guthrie Typesetter: Gordan salinovic Cover designer: Marija Tudor ISBN9781617292545 Printed in the United states of america 12345678910-EBM-201918171615 contents foreword vii preface ix about this book xii acknowledgments xu Bootstarting Spring I 1.1 Spring rebooted 2 Taking afresh look at spring 2 Examining Spring Boot essentials 4. What Spring Boot isnt 7 1. 2 Getting started with Spring boot Installing the spring Boot ClI 8 Initializing a spring Boot project with spring Initializr 12 1.3 Summary 22 Developing your first Spring Boot application 23 2.1 Putting Spring Boot to work 24 Examining a newly initialized spring Boot project 26. Dissecting a spring boot t build 30 2.2 Using starter dependencies 33 Specifying facet-based dependencies 34. Overriding starter transitive dependencies 35 CONTENTS 2.3 USing automatic configuration 37 Focusing on application functionality 37 Running the application 43. What just happened? 45 2.4 Summary 48 Customizing configuration 49 3.1 Overriding Spring Boot auto-configuration 50 Securing the application 50. Creating a custom security configuration 51 Taking another peek under the covers of auto-configuration 55 8.2 Externalizing configuration with properties 57 Fine-tuning auto-configuration 58 Externally configuring application beans 64. Configuring with profiles 69 8.3 Customizing application error pages 71 3.4 Summary 74 Testing with Spring Boot 76 4.1 Integration testing auto-configuration 77 4.2 Testing web applications 79 Mocking Spring Mvc 80. Testing web security 83 4.8 Testing a running application 86 Starting the server on a random port 87- Testing hTml pages with selenium 88 4.4 Summary 90 Getting Groovy with the Spring Boot CLI 92 5.1 Developing a Spring Boot ClI application 98 Setting up the cli project 93. Eliminating code noise with Groovy 94. What just happened? 98 5.2 Grabbing dependencies 100 Overriding default dependency versions 101. Adding dependency repositories 102 5.3 Running tests with the cli 102 5.4 Creating a deployable artifact 105 5.5 Summary 106 CONTENTS 6 Applying Grails in Spring Boot 107 6.1 Using gorm for data persistence 108 6.2 Defining views with Groovy Server Pages 118 6.3 Mixing spring boot with grails 3 115 Creating a new Grails project 116 Defining the domain 118 Writing a grails controller 119. Creating the view 120 6. Summary 123 Taking a peek inside with the Actuator 124 7.1 Exploring the Actuator's endpoints 125 Viewing configuration details 126. Tapping runtime metrics 133 Shutting down the application 139. Fetching application information 140 7.2 Connecting to the Actuator remote shell 141 Viewing the autoconfig report 142. Listing application beans 143 Watching application metrics 144. Invoking actuator endpoints 145 7. 3 Monitoring your application with JMX 146 7.4 Customizing the Actuator 148 Changing endpoint Ds 148 Enabling and disabling endpoints 149 Adding custom metrics and gauges 149- Creating a custom trace repository 153. Plugging in custom health indicators 155 7.5 Securing Actuator endpoints 156 7.6 Summary 159 8 Deploying Spring Boot applications 160 8.1 Weighing deployment options 161 8.2 Deploying to an application server 162 Building a Warfile 162 Creating a production profile 164 Enabling database migration 168 8.3 Pushing to the cloud 173 Deploying to Cloud Foundry 173. Deploying to Heroku 177 8.4 Summary 180 endix a spring boot Developer Tools 181 appendix b spring boot starters 188 appendix c Configuration properties 195 appendixd spring boot dependencies 232 index 243 In the spring of 2014, the Delivery Engineering team at Netflix set out to achieve a lofty goal: enable end-to-end global continuous delivery via a software platform that facilitates both extensibility and resiliency. my team had previously built two different applications attempting to address Netflix's delivery and deployment needs, but both were beginning to show the telltale signs of monolith-ness and neither met the goals of flexibility and resiliency. what's more, the most stymieing effect of these monolithic applications was ultimately that we were unable to keep pace with our partner's inno- vation. Users had begun to move around our tools rather than with them It became apparent that if we wanted to provide real value to the company and rap idly innovate, we needed to break up the monoliths into small, independent services that could be released at will. Embracing a microservice architecture gave us hope that we could also address the twin goals of flexibility and resiliency. But we needed to do it on a credible foundation where we could count on real concurrency, legitimate moni toring, reliable and easy service discovery, and great runtime performance With the JVM as our bedrock, we looked for a framework that would give us rapid velocity and steadfast operationalization out of the box. We zeroed in on Spring Boot pring Boot makes it effortless to create Spring-powered, production-ready ser- vices without a lot of code! Indeed, the fact that a simple Spring Boot Hello world application can fit into a tweet is a radical departure from what the same functionality required on the ivm only a few short years ago. Out-of-the-box nonfunctional features like security, metrics, health-checks, embedded servers, and externalized configura tion made boot an easy choice for us FOREWORD Yet, when we embarked on our Spring boot journey, solid documentation was hard to come by Relying on source code isnt the most joyful manner of figuring out how to properly leverage a frameworks features It's not surprising to see the author of mannings venerable spring in action take on the challenge of concisely distilling the core aspects of working with Spring Boot into another cogent book. Nor is it surprising that Craig and the manning crew have done another tremendously wonderful job! Spring Boot in Action is an easily readable book, as we've now come to expect from Craig and manning From chapter Is attention-getting introduction to Boot and the now legend- ary gOish-character tweetable Boot application to an in-depth analysis of Boots Actuator in chapter 7, which enables a host of auto-magical operational features required for any production application, Spring Boot in Action leaves no stone unturned. Indeed, for me, chapter 7's deep dive into the Actuator answered some of the lingering questions I've had in the back of my head since picking up boot well over a year ago. Chapter 8s thor ough examination of deployment options opened my eyes to the simplicity of cloud Foundry for cloud deployments. One of my favorite chapters is chapter 4, where Craig explores the many powerful options for easily testing a Boot application. From the get- go, I was pleasantly surprised with some of Springs testing features, and Boot takes advantage of them nicely As I've publicly stated before, Spring Boot is just the kind of framework the java community has been seeking for over a decade. Its easy-to-use development features and out-of-the-box operationalization make Java development fun again. I'm pleased to report that Spring and Spring Boot are the foundation of Netflix's new continuous delivery platform. What's more, other teams at Netflix are following the same path because they too see the myriad benefits of boot It's with equal parts excitement and passion that I absolutely endorse craigs book as the easy-to-digest and fun-to-read Spring Boot documentation the Java community has been waiting for since boot took the community by storm. Craigs accessible writ- ing style and sweeping analysis of boot's core features and functionality will surely leave readers with a solid grasp of boot (along with a joyful sense of awe for it) Keep up the great work Craig, Manning Publications, and all the brilliant develop ers who have made Spring Boot what it is today! Each one of you has ensured a bright future for the JVM ANDREW GLOVER ANAGER, DELIVERY ENGINEERING AT NETFLIX eface At the 1964 New York Worlds Fair, Walt Disney introduced three groundbreaking attractions:“it' s a small world,”“ Great moments with mr. Lincoln,” and the“ Carousel of Progress. All three of these attractions have since moved into disneyland and walt Disney world, and you can still see them today My favorite of these is the carousel of Progress. Supposedly it was one of walt Disneys favorites too. It's part ride and part stage show where the seating area rotates around a center area featuring four stages. Each stage tells the story of a family at different time periods of the 20th century-the early 1900s the 1920s the 1940s, and recent times--highlighting the technology advances in that time period. The story of innovation is told from a hand- cranked washing machine, to electric lighting and radio, to automatic dishwashers and television, to computers and voice-activated appliances In every act, the father (who is also the narrator of the show) talks about the latest inventions and says It cant get any better, only to discover that, in fact, it does get better in the next act as technology progresses Although Spring doesn't have quite as long a history as that displayed in the Car ousel of Progress, I feel the same way about Spring as"Progress Dad" felt about the 20th century. each and every spring application seems to make the lives of developer so much better. Just looking at how Spring components are declared and wired together, we can see the following progression over the history of spring

...展开详情
试读 266P Spring Boot in Action
立即下载 低至0.43元/次 身份认证VIP会员低至7折
一个资源只可评论一次,评论内容不能少于5个字
您会向同学/朋友/同事推荐我们的CSDN下载吗?
谢谢参与!您的真实评价是我们改进的动力~
  • 签到新秀

关注 私信
上传资源赚钱or赚积分
最新推荐
Spring Boot in Action 9积分/C币 立即下载
1/266
Spring Boot in Action第1页
Spring Boot in Action第2页
Spring Boot in Action第3页
Spring Boot in Action第4页
Spring Boot in Action第5页
Spring Boot in Action第6页
Spring Boot in Action第7页
Spring Boot in Action第8页
Spring Boot in Action第9页
Spring Boot in Action第10页
Spring Boot in Action第11页
Spring Boot in Action第12页
Spring Boot in Action第13页
Spring Boot in Action第14页
Spring Boot in Action第15页
Spring Boot in Action第16页
Spring Boot in Action第17页
Spring Boot in Action第18页
Spring Boot in Action第19页
Spring Boot in Action第20页

试读结束, 可继续阅读

9积分/C币 立即下载 >