Pro+Spring+5

所需积分/C币:13 2018-09-11 07:39:38 9.86MB PDF
2
收藏 收藏
举报

Pro+Spring+5 高清
Pro Spring 5: An In-Depth Guide to the Spring framework and Its Tools Iuliana cosmin Rob Harrop Sibiu, sibiu romania Reddish, United Kingdom Chris Schaefer Clarence ho Venice, Florida, USA Hong Kong, China ISBN-13(pbk:978-1-48422807-4 ISBN-13( electronic):978-1-4842-2808-1 DOI10.1007/978-1-4842-2808-1 Library of Congress Control Number: 2017955423 Copyright o 2017 by juliana 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 CoverimagebyFreepik(www.freepik.com Managing Director: Welmoed Spahr Editorial director: Todd green Acquisitions Editor: Steve Anglin Development Editor: Matthew Moodie Technical reviewer: Massimo nardone Coordinating editor: Mark Powers Copy Editor: Kim Wimpsett 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-nyospringer-sbm.comorvisitwww.springeronline.comApressMedia,LlcisaCaliforniaLlc and the sole member(owner )is Springer Science Business Media Finance Inc (SSBM Finance Inc) SSBM Finance Inc is a Delaware corporation Forinformationontranslationspleasee-mailrights@apress.comorvisitwww.apress.com/ rights- permissions press titles 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 print and ebook bulk Saleswebpageatwww.apress.com/bulk-sales Any source code or other supplementary material referenced by the author in this book is available to readersonGithubviathebooksproductpagelocatedatwww.apRess.com/9781484228074.Formore detailedinformationpleasevisitwww.apress.com/source-code Printed on acid-free paper I dedicate this book to my friends, to my godson stefan, and to all the musicians who have made working on this book easy with their music Juliana cosmin Contents at a glance About the authors ■■■■■■■■■■■ About the technical reviewer xXV Acknowledgments ammmmmamnmmaaaamammamaamnmmaaaamnmamaanm XXVii Introduction ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ XXIX Chapter 1: Introducing Spring ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■國■■■■ Chapter 2: Getting Started mamaaamamammmmam 19 Chapter3; ntroducing loc and DI in Spring…,,,,,…mm,,m……37 Chapter 4: Spring Configuration in Detail and Spring Boot mmmammma 125 Chapter 5: Introducing Spring AOPmmma ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■口■■■ 211 Chapter 6: Spring JDBC Support ammammmmmm RBIBIRRIBIaRImIaRInaam 297 Chapter7: Using Hibernate in Spring…,,,…,,,,,,,,,,…,,……355 Chapter 8: Data Access in Spring with JPA2 maaaa maI 393 Chapter 9: Transaction Management ammmammammmmmmamaama 467 Chapter 10: Validation with Type Conversion and Formatting mm 509 Chapter11: Task Scheduling…,,…,,,,,m,…,,,,m…m,m,,,537 Chapter 12: Using Spring 557 Chapter 13: Spring Testing mmmmmammammm ImmI 615 ■ Chapter14: Scripting Support in Spring,,,,…,,,,…,639 Chapter 15: Application Monitoring aaaaaaaaaa aRaananaaa aIIIRRLaan 655 CONTENTS AT A GLANCI Chapter 16: Web Applications nmmamaamaammmaammmmamm 665 Chapter 17: Web Socket tr ■■■■■■■■國■■■■■■■■■■■■■■■■■■■■■■■國■■■■■■■■■■■國■■■■■■■■■■■■■国a■■■■a■国 751 Chapter 18: Spring Projects: Batch, Integration, XD, and More mm 773 Appendix A: Setting Up Your Development Environment 829 Index 841 Contents About the authors ■■■■■■■■■■■ About the technical reviewer xXV Acknowledgments ammaaaamammaaamammmmamamammmmaaaammmaaaannma xxvii Introduction m xxix Chapter 1: Introducing Spring ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■國■■■■ What Is Spring 112 Evolution of the spring Framework Inverting Control or Injecting Dependencies?........................8 Evolution of Dependency Injection 8 Beyond Dependency Injection.. The Spring project 15 Origins of Spring...... 15 The Spring community 15 The Spring Tool Suite..........................................16 The Spring security project Spring boot Spring batch and Integration.…………17 Many other Projects.............. 17 Alternatives to Spring… 17 JBoSsSeamFramework…17 Google Guice 17 Picocontainerwwwwww.17 JEE 7 Container Summary 18 CONTENTS Chapter 2: Getting Startedaammmmmmmmaammmmnm 19 Obtaining the Spring Framework 20 Getting Started Quickly 20 Checking Spring Out of GitHub Using the Right JDK… 21 Understanding Spring Packaging………21 Choosing Modules for Your Application 24 Accessing Spring Modules on the Maven Repository. .............24 Accessing Spring Modules Using Gradle................... Using Spring Documentation....... Putting a Spring into Hello World 27 Building the Sample Hello World Application.............……….27 Refactoring with spring ..........................................................................................31 Summary…….......……………35 Chapter 3: Introducing loc and DI in Spring ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■ 37 Inversion of control and dependency Injection. mmmmmmmmemmnnn 37 Types of Inversion of Control...... 38 Dependency Pull Contextualized Dependency Lookup 39 Constructor Dependency Injection Setter Dependency Injection................................41 Injection VS. Lookup ,41 Setter Injection vs. Constructor Injection 42 Inversion of Control in Spring 5 Dependency Injection in Spring 46 Beans and Bean Factory . Bean Factory Implementations....,.,.,,,………,46 ApplicationContext.…...…48 Configuring ApplicationContext 48 Setting Spring Configuration Options Basic Configuration Overview CONTENTS Declaring Spring Components….....…………50 Using Method Injection Understanding Bean Naming…,,,,………………95 Understanding Bean Instantiation Mod Resolving dependencies 109 Autowiring Your Bean…… …112 When to Use Autowiring Setting Bean Inheritance.......……122 Summary 124 Chapter 4: Spring Configuration in Detail and Spring Boot ammm 125 Spring's Impact on Application Portability 126 Bean Life-Cycle Management …127 Hooking into Bean Creation 128 Executing a Method When a Bean Is created.......... 128 Implementing the Initializing Bean Interface 132 Using the JSR- 250 @PostConstruct Annotation Declaring an Initialization Method using @Bean..mm...m.... 137 Understanding Order of Resolution ...................................138 Ho0 king into Bean Destructi0n...……139 Executing a Method When a Bean Is Destroyed 139 Implementing the DisposableBean Interface. Using the JSR-250@ PreDestroy Annotation........………,143 Declaring a Destroy Method Using @Bean....om..eo.... 144 Understanding Order of Resolution.m....m..m....146 Using a Shutdown Hook 146 Making Your Beans“ Spring Aware” 146 Using the bean Name Aware Interface Using the application ContextAware Interface. Use of Factory beans 151 Factory Bean EXample: The MessageDigestFactory Bean CONTENTS Accessing a Factory Bean Directly 156 Using the factory-bean and factory-method Attributes 157 JavaBeans PropertyEditors )usssnsssnsssnnssnnssnnssnsssnnssnnssnnssnBSSEIIE ,158 Using the built-in Property Editors.......................... 159 Creating a Custom Property Editor 164 More Spring application Context Configuration .. Internationalization with the Message Source 168 Using Message Source in Stand-Alone applications..........................171 Application Events Accessing Resources 174 Configuration Using Java classes . ApplicationContext Configuration in Java................................175 Spring mixed configuration....…………185 Java or XML Configuration? 187 Profiles 187 An Example of Using the Spring Profiles Feature...........................187 Spring Profiles Using Java configuration.............. ,190 Considerations for Using profiles Environment and Property Source Abstraction……,,,,…,… 193 Configuration Using JSR-330 Annotations ,198 Configuration Using Groovy…,,,.,,.,,… 201 Spring Boot.… 204 Summary… 210 Chapter 5: Introducing Spring AOP. ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■■■■■■■■■口■■■■■国■口国■■ 211 AOP Concepts 212 Types of AOP.. 213 Using Static AOP… 213 Using dynamic AOP 213 Choosing an AoP Type .

...展开详情
试读 127P Pro+Spring+5
立即下载 低至0.43元/次 身份认证VIP会员低至7折
抢沙发
一个资源只可评论一次,评论内容不能少于5个字
上传资源赚积分or赚钱
    最新推荐
    Pro+Spring+5 13积分/C币 立即下载
    1/127
    Pro+Spring+5第1页
    Pro+Spring+5第2页
    Pro+Spring+5第3页
    Pro+Spring+5第4页
    Pro+Spring+5第5页
    Pro+Spring+5第6页
    Pro+Spring+5第7页
    Pro+Spring+5第8页
    Pro+Spring+5第9页
    Pro+Spring+5第10页
    Pro+Spring+5第11页
    Pro+Spring+5第12页
    Pro+Spring+5第13页
    Pro+Spring+5第14页
    Pro+Spring+5第15页
    Pro+Spring+5第16页
    Pro+Spring+5第17页
    Pro+Spring+5第18页
    Pro+Spring+5第19页
    Pro+Spring+5第20页

    试读结束, 可继续阅读

    13积分/C币 立即下载 >