Apress.Beginning.Spring.5.From.Novice.to.Professional.pdf

所需积分/C币:9 2019-09-07 09:22:51 3.23MB PDF
收藏 收藏
举报

Get started with Spring Framework 5 and its ecosystem, with a guide to the working practices in modern development. This book will teach you how to use the Spring Framework to build Java-based applications, web applications, and microservices. You’ll see how Spring has drastically and positively aff
Beginning Spring 5: From Novice to Professional Joseph B ottinger Andrew lombard YOUNGSVILLE NC, USA Laguna Beach, CA, USA ISBN13(pbk):978-1-4842-4485-2 ISBN-13( electronic:978-1-4842-4486-9 htps:// doi. org/10.1007/978-1-4842-4486-9 Copyright C 2019 by Joseph B Ottinger and Andrew Lombardi 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: Matthew Moodie Coordinating Editor: Mark Powers Cover designed by eStudio Calamar CoverimagedesignedbyFreepik(www.freepik.com) 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 orders-ny@springer- sbm.com,orvisitwww.springeronline.com.ApressMedia,LlcisaCaliforniaLlcandthesolemember (owner) is Springer Science Business Media Finance Inc(SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation Forinformationontranslations,pleasee-maileditorial@apress.com;forreprint,paperback,oraudiorights, please email bookpermissions @springernature com Apress titles may be purchased in bulk for academic, corporate, or promotional use e Book versions and licenses are also available for most titles. For more information reference our print and ebook bulk sales webpageathttp://www.apress.com/bulk-sales Any source code or other supplementary material referenced by the author in this book is available to readersonGithubviathebooksproductpagelocatedatwww.apress.com/9781484244852.Formore detailedinformationpleasevisithttp://www.apress.com/source-code Printed on acid-free paper To our loved ones and whirled peas Table of contents About the authors ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■圆■■■■■国■■ About the technical reviewer Acknowledgments ■■■■■■■■■■■ ■■■■■■■■■■■■ ■■■■■ Chapter 1: History and Justification 1.1 Setting the Stage for Better Development….,.,,,,,,,,,…,…1 1.2 Rod and Juergen Change the(Java)World. 1.3 The Lever: Dependency Injection 689 1.3.1J2 EE Hello world,asof2005...………… 1.3.2 Spring,'s Better Vision of Hello World ■■重D面重重,面重D面重夏重 12 14 Spring breaks Free and Fⅸ xes java ee… 15 1.5 Next Steps 15 Chapter2Helo,Word!,,…,…,…,,,…,,,,,111,17 2. 1 A Simple Application 17 2.1.1 Suffering-Oriented Programming 2.2 Building…..............,,………20 2.2.1 Installing gradle 21 2.2.2 Building the Project............................. 22 2.3 Testing..,…26 2. 4 A Simple Application with Spring. 2.5 Next Steps 34 Chapter 3: Configuration and Declaration of Beans. 35 3.1 The container 3.2 The Sample application 3.2.1 The Code for the Band Gateway TABLE OF CONTENTS 3. 3 Configuration Through Annotation . 3. 3. 1 Declaring a Spring Bean with @Component .50 3.3.2 Wiring Components Together with @Autowired.......mmmmmm.55 3.3.3 Choosing Components with @Qualifier and Bean Names 62 3.3 4 Constructor Injection with Annotations 69 3.4 Configuration Through XML 3.4.1 Declaring a bean with <bean 779 3.4.2 Wiring Components Together with <property / 3.4.3 Wiring Components Together with <constructor-arg / 3.5 Configuration Through Java 84 3.5. 1 Declaring Components with @ 3.5.2 Using a Programmatic Configuration for ApplicationContext 86 3.5.3 Wiring Components Together with @Autowired with Static Configuration 87 3.5.4 Using @Qualifier to Select Specific Components for Wiring I 88 35.5 Constructor Injection with Static Configuration……… n.89 3.5.6 Testing Every Configuration with a DataProvider. 3.6 Next Steps…95 Chapter 4: Lifecycle ■■■■■■■■■■■■口■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■口■■■■■■■■■■■■■■■■■■■■口■■ 97 4.1 Introduction of Lifecycle......,,…………97 4.1.1Sc0pe.....98 4.1.2 Calling constructors......................103 4.1. 3 Calling methods After construction and before Destruction 105 4.1.4LifecycleListeners....108 4.2 Lifecycle with JSR-250 Annotations . 4.2.1 Annotated Beans with Scopes 110 4.2.2C0 nstructors with annotated classes……113 4.2. 3 Calling methods After Construction and before destruction mmm 113 4.3 Lifecycle with Java Configuration 16 4.4 Additional Scopes,.,.,.,.,.,.,.,.,.,.,.,, 119 4.5 Next steps...,,,,,,……119 TABLE OF CONTENTS Chapter 5: Spring and Jakarta EEmmmmmm 121 5.1 Introduction to jakarta ee 121 5.1.1 The servlet apl 122 5.1.2 Modern Web application Design Principles 125 5.2 Module structure 125 5.2.1 The Common module 126 5.2.2 The Annotation-Based Web application .mamamnammmamamnmnanatmn 130 5.2.3 The XML-Based Spring Context Application 140 5.3 Next Steps 143 Chapter6: Spring Web,,,,…,,,,,,…,,,,,,,,,…145 6.1 Introduction to Spring mvc 145 6.2 MVC 145 6. 3 Hello, World with mvc.m. ……146 6.3.1 REST Concepts ■重,面面重D面重D重,重1D面重重重面重 149 6.4 Developing Our First Endpoint with MVC 152 6.5 Configuration...,.,,,,,,,………159 6.6 Templates and Models. 67 Error Handling…,,,,,,,,,…164 6.8 Next Steps..........,167 Chapter 7: Spring boot maar ■■■■■■■■■■■ n169 7.1 What Is spring boot?..……169 7.2 Setting Up a project 171 7.3 Checking the Foundation…… 172 7.3.1 Building the Application....,,…………173 7.3.2 Building Our Transport object. 7.3.3 Actually Saying“"Helo”. 175 7. 3. 4 Testing with Spring Boot....mmmmmmmmnmmmmmmn 176 7.3.5 Configuration in Spring Boot…………… 179 7.3.6 Static Content with Spring Boot 180 7.3.7 Summary of the"Hello, World"Boot Mechanism.am.mammmmmmmaammn 182 TABLE OF CONTENTS 7. 4 Spring Boot and Database Connections...................... 183 7. 4.1 Initializing Data with Spring Boot.emmmmmmmmmmmmmmmannmmmmmmmmn 184 7.4.2 Building an Artistservice 188 7.4.3 Handling Exceptions in Spring Boot 192 7.4.4 The Actual Implementation of Artistservice and Its Little controller, ToO 194 7.4.5 Testing Our ArtistController: Does It Work 7.5 Next Steps...................,.,,,205 Chapter 8: Spring Data Access with JdbcTemplateaa ■■■■■■■■■口■■口■■口■■■■ 207 8.1 Introduction 207 8.2 Project Setup. 8.2.1 Lombok: Eliminating Boilerplate Code.mn. ■■重D面重重,■面重D重夏D■ 210 8. 3 our Entity and Data Models 216 8.4 Accessing Data............... 222 8.4.1 JdbcTemplate 8.4.@Transactional 228 8.4.3 The Actual MusicRepository. 8.5 Adding the REST Endpoints............................ 243 8.5.1 The artistcontroller 244 8.5.2 The SongController. 8.6 Next Steps Chapter 9: Persistence with Spring and Spring Data nn 261 9.1 Introduction 261 9.2 General Architecture 262 9.2.1 An Important Note about requirements. emaanenannaaaanannananaannn 264 9.3 Creating Our Project Structure 264 9.3.1 The Common code 9.3.2 The chaptergtest Project 281 9.3.3 The chaptergjpa Project 291 9.3.4 The chaptergmongodb Project........................ 301 TABLE OF CONTENTS 9.3.5 Getting MongoDB. 9.3.6 The Code for the chaptergmongodb Project 1302 9.4 Tying Up Loose Ends 9.5 Next Steps. Chapter 10: Spring Security 313 10.1 Introduction 313 10.2 Configuration.m......mmmmmmmmmmmmmmmmmmmmmmmmm 315 10.2.1 Customizing Your Security 327 10.3 Securing a rest application.………………………………332 10.4 New in Spring Security 5... 339 10.4.1 OAuth 2.0 Login. 10.4.2 Reactive Support . 10.4.3 DelegatingPassword Encoder mm 10.5 Next Steps ……343 Chapter 11: Next Steps. mmmaant ■■■■■ ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ na345 11. 1 Spring WebMVC fn 345 11.2 Spring Reactive. 113 Message Queues and spring…,.,,.,,,………,…349 114 GraphQL.......………351 11.5 Rivescript 353 11.6 What's next?mmmm 356 Index ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 357 About the authors Joseph B Ottinger(@josephbottinger )is a distributed systems architect with experience in many cloud platforms. He was the editor-in-chief of both Java Developer Journal and The Server Side. com and has also contributed to many, many publications, open source projects, and commercial projects over the years, using many different languages(but primarily Java, Python, and Java Script). He's also a previously published author online (with too many publications to note individually and in print, through apress Andrew Lombardi(kinabalu)is a veteran entrepreneur and systems engineer. He's run the successful boutique consulting firm Mystic Coders for 18 years. With his team they ve helped companies as large as Walmart and firms with problems as interesting as helicopter simulation. A few years ago, he authored a book on Web Socket for O'Reilly which focused on the server and client components all written with JavaScript and Node js. He firmly believes that the best thing he's done so far is being a great dad

...展开详情
试读 367P Apress.Beginning.Spring.5.From.Novice.to.Professional.pdf
立即下载 低至0.43元/次 身份认证VIP会员低至7折
抢沙发
一个资源只可评论一次,评论内容不能少于5个字
  • 分享王者

    成功上传51个资源即可获取
关注 私信 TA的资源
上传资源赚积分,得勋章
最新推荐
Apress.Beginning.Spring.5.From.Novice.to.Professional.pdf 9积分/C币 立即下载
1/367
Apress.Beginning.Spring.5.From.Novice.to.Professional.pdf第1页
Apress.Beginning.Spring.5.From.Novice.to.Professional.pdf第2页
Apress.Beginning.Spring.5.From.Novice.to.Professional.pdf第3页
Apress.Beginning.Spring.5.From.Novice.to.Professional.pdf第4页
Apress.Beginning.Spring.5.From.Novice.to.Professional.pdf第5页
Apress.Beginning.Spring.5.From.Novice.to.Professional.pdf第6页
Apress.Beginning.Spring.5.From.Novice.to.Professional.pdf第7页
Apress.Beginning.Spring.5.From.Novice.to.Professional.pdf第8页
Apress.Beginning.Spring.5.From.Novice.to.Professional.pdf第9页
Apress.Beginning.Spring.5.From.Novice.to.Professional.pdf第10页
Apress.Beginning.Spring.5.From.Novice.to.Professional.pdf第11页
Apress.Beginning.Spring.5.From.Novice.to.Professional.pdf第12页
Apress.Beginning.Spring.5.From.Novice.to.Professional.pdf第13页
Apress.Beginning.Spring.5.From.Novice.to.Professional.pdf第14页
Apress.Beginning.Spring.5.From.Novice.to.Professional.pdf第15页
Apress.Beginning.Spring.5.From.Novice.to.Professional.pdf第16页
Apress.Beginning.Spring.5.From.Novice.to.Professional.pdf第17页
Apress.Beginning.Spring.5.From.Novice.to.Professional.pdf第18页
Apress.Beginning.Spring.5.From.Novice.to.Professional.pdf第19页
Apress.Beginning.Spring.5.From.Novice.to.Professional.pdf第20页

试读结束, 可继续阅读

9积分/C币 立即下载 >