基本信息
源码名称:spring实战第五版源码(含英文版pdf)
源码大小:16.37M
文件格式:.zip
开发语言:Java
更新时间:2021-07-24
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
spring实战第五版源码_102812
spring实战第五版源码_102812
contents preface xiii acknowledgments xv about this book xvii PART 1FOUNDATIONAL SPRING ......................................1 1 Getting started with Spring 3 1.1 What is Spring? 4 1.2 Initializing a Spring application 6 Initializing a Spring project with Spring Tool Suite 7 Examining the Spring project structure 11 1.3 Writing a Spring application 17 Handling web requests 17 ■ Defining the view 19 Testing the controller 20 ■ Building and running the application 21 ■ Getting to know Spring Boot DevTools 23 Let’s review 25 1.4 Surveying the Spring landscape 26 The core Spring Framework 26 ■ Spring Boot 26 Spring Data 27 ■ Spring Security 27 ■ Spring Integration and Spring Batch 27 ■ Spring Cloud 28 vi CONTENTS 2 Developing web applications 29 2.1 Displaying information 30 Establishing the domain 31 ■ Creating a controller class 32 Designing the view 35 2.2 Processing form submission 40 2.3 Validating form input 45 Declaring validation rules 46 ■ Performing validation at form binding 48 ■ Displaying validation errors 49 2.4 Working with view controllers 51 2.5 Choosing a view template library 52 Caching templates 54 3 Working with data 56 3.1 Reading and writing data with JDBC 57 Adapting the domain for persistence 59 ■ Working with JdbcTemplate 60 ■ Defining a schema and preloading data 64 Inserting data 66 3.2 Persisting data with Spring Data JPA 75 Adding Spring Data JPA to the project 76 ■ Annotating the domain as entities 76 ■ Declaring JPA repositories 80 Customizing JPA repositories 81 4 Securing Spring 84 4.1 Enabling Spring Security 85 4.2 Configuring Spring Security 86 In-memory user store 88 ■ JDBC-based user store 89 LDAP-backed user store 92 ■ Customizing user authentication 96 4.3 Securing web requests 103 Securing requests 104 ■ Creating a custom login page 106 Logging out 109 ■ Preventing cross-site request forgery 109 4.4 Knowing your user 110 5 Working with configuration properties 114 5.1 Fine-tuning autoconfiguration 115 Understanding Spring’s environment abstraction 116 Configuring a data source 117 ■ Configuring the embedded server 119 ■ Configuring logging 120 ■ Using special property values 121 CONTENTS vii 5.2 Creating your own configuration properties 122 Defining configuration properties holders 124 ■ Declaring configuration property metadata 126 5.3 Configuring with profiles 129 Defining profile-specific properties 130 ■ Activating profiles 131 Conditionally creating beans with profiles 132 PART 2INTEGRATED SPRING .......................................135 6 Creating REST services 137 6.1 Writing RESTful controllers 138 Retrieving data from the server 140 ■ Sending data to the server 145 ■ Updating data on the server 146 ■ Deleting data from the server 148 6.2 Enabling hypermedia 149 Adding hyperlinks 152 ■ Creating resource assemblers 154 Naming embedded relationships 159 6.3 Enabling data-backed services 160 Adjusting resource paths and relation names 162 ■ Paging and sorting 164 ■ Adding custom endpoints 165 ■ Adding custom hyperlinks to Spring Data endpoints 167 7 Consuming REST services 169 7.1 Consuming REST endpoints with RestTemplate 170 GETting resources 172 ■ PUTting resources 173 DELETEing resources 174 ■ POSTing resource data 174 7.2 Navigating REST APIs with Traverson 175 8 Sending messages asynchronously 178 8.1 Sending messages with JMS 179 Setting up JMS 179 ■ Sending messages with JmsTemplate 181 Receiving JMS messages 188 8.2 Working with RabbitMQ and AMQP 192 Adding RabbitMQ to Spring 193 ■ Sending messages with RabbitTemplate 194 ■ Receiving message from RabbitMQ 198 8.3 Messaging with Kafka 202 Setting up Spring for Kafka messaging 203 ■ Sending messages with KafkaTemplate 204 ■ Writing Kafka listeners 206 viii CONTENTS 9 Integrating Spring 209 9.1 Declaring a simple integration flow 210 Defining integration flows with XML 211 ■ Configuring integration flows in Java 213 ■ Using Spring Integration’s DSL configuration 215 9.2 Surveying the Spring Integration landscape 216 Message channels 217 ■ Filters 219 ■ Transformers 220 Routers 221 ■ Splitters 223 ■ Service activators 225 Gateways 227 ■ Channel adapters 228 ■ Endpoint modules 230 9.3 Creating an email integration flow 231 PART 3REACTIVE SPRING ...........................................239 10 Introducing Reactor 241 10.1 Understanding reactive programming 242 Defining Reactive Streams 243 10.2 Getting started with Reactor 245 Diagramming reactive flows 246 ■ Adding Reactor dependencies 247 10.3 Applying common reactive operations 248 Creating reactive types 249 ■ Combining reactive types 253 Transforming and filtering reactive streams 257 ■ Performing logic operations on reactive types 266 11 Developing reactive APIs 269 11.1 Working with Spring WebFlux 269 Introducing Spring WebFlux 271 ■ Writing reactive controllers 272 11.2 Defining functional request handlers 276 11.3 Testing reactive controllers 279 Testing GET requests 279 ■ Testing POST requests 282 Testing with a live server 284 11.4 Consuming REST APIs reactively 285 GETting resources 285 ■ Sending resources 287 Deleting resources 288 ■ Handling errors 289 Exchanging requests 290 CONTENTS ix 11.5 Securing reactive web APIs 292 Configuring reactive web security 292 ■ Configuring a reactive user details service 294 12 Persisting data reactively 296 12.1 Understanding Spring Data’s reactive story 297 Spring Data reactive distilled 297 ■ Converting between reactive and non-reactive types 298 ■ Developing reactive repositories 300 12.2 Working with reactive Cassandra repositories 300 Enabling Spring Data Cassandra 301 ■ Understanding Cassandra data modeling 303 ■ Mapping domain types for Cassandra persistence 304 ■ Writing reactive Cassandra repositories 309 12.3 Writing reactive MongoDB repositories 312 Enabling Spring Data MongoDB 312 ■ Mapping domain types to documents 314 ■ Writing reactive MongoDB repository interfaces 317 PART 4CLOUD-NATIVE SPRING....................................321 13 Discovering services 323 13.1 Thinking in microservices 324 13.2 Setting up a service registry 326 Configuring Eureka 330 ■ Scaling Eureka 333 13.3 Registering and discovering services 334 Configuring Eureka client properties 335 ■ Consuming services 337 14 Managing configuration 343 14.1 Sharing configuration 344 14.2 Running Config Server 345 Enabling Config Server 346 ■ Populating the configuration repository 349 14.3 Consuming shared configuration 352 14.4 Serving application- and profile-specific properties 353 Serving application-specific properties 354 ■ Serving properties from profiles 355 14.5 Keeping configuration properties secret 357 Encrypting properties in Git 357 ■ Storing secrets in Vault 360 x CONTENTS 14.6 Refreshing configuration properties on the fly 364 Manually refreshing configuration properties 365 Automatically refreshing configuration properties 367 15 Handling failure and latency 376 15.1 Understanding circuit breakers 376 15.2 Declaring circuit breakers 378 Mitigating latency 381 ■ Managing circuit breaker thresholds 382 15.3 Monitoring failures 383 Introducing the Hystrix dashboard 384 ■ Understanding Hystrix thread pools 387 15.4 Aggregating multiple Hystrix streams 389 PART 5DEPLOYED SPRING ..........................................393 16 Working with Spring Boot Actuator 395 16.1 Introducing Actuator 396 Configuring Actuator’s base path 397 ■ Enabling and disabling Actuator endpoints 398 16.2 Consuming Actuator endpoints 399 Fetching essential application information 400 ■ Viewing configuration details 403 ■ Viewing application activity 411 Tapping runtime metrics 413 16.3 Customizing Actuator 416 Contributing information to the /info endpoint 416 Defining custom health indicators 421 ■ Registering custom metrics 422 ■ Creating custom endpoints 424 16.4 Securing Actuator 426 17 Administering Spring 429 17.1 Using the Spring Boot Admin 430 Creating an Admin server 430 ■ Registering Admin clients 431 17.2 Exploring the Admin server 435 Viewing general application health and information 436 Watching key metrics 437 ■ Examining environment properties 438 ■ Viewing and setting logging levels 439 Monitoring threads 440 ■ Tracing HTTP requests 441 CONTENTS xi 17.3 Securing the Admin server 442 Enabling login in the Admin server 443 ■ Authenticating with the Actuator 444 18 Monitoring Spring with JMX 446 18.1 Working with Actuator MBeans 446 18.2 Creating your own MBeans 449 18.3 Sending notifications 451 19 Deploying Spring 454 19.1 Weighing deployment options 455 19.2 Building and deploying WAR files 456 19.3 Pushing JAR files to Cloud Foundry 458 19.4 Running Spring Boot in a Docker container 461 19.5 The end is where we begin 465 appendix Bootstrapping Spring applications 466 index 487