Beginning Spring 6: From Beginner to Pro. 2 Ed

Beginning Spring 6: From Beginner to Pro. 2 Ed

Beginning Spring 6: From Beginner to Pro. 2 Ed
Автор: Lombardi Andrew, Ottinger Joseph B.
Дата выхода: 2024
Издательство: Apress Media, LLC.
Количество страниц: 435
Размер файла: 1.7 MB
Тип файла: PDF
Добавил: codelibs
 Проверить на вирусы  Дополнительные материалы 

Table of Contents....5

About the Authors....11

About the Technical Reviewer....12

Acknowledgments....13

Chapter 1: History and Justification....14

Setting the Stage for Better Development....14

Rod and Juergen Change the (Java) World....19

The Lever: Dependency Injection....21

J2EE Hello World, As of 2005....22

Spring’s Better Vision of Hello World....25

Spring Breaks Free and Fixes Java EE....27

Spring 6 and Modern Java....28

Next Steps....29

Chapter 2: Hello, World!....30

A Simple Application....30

Suffering-Oriented Programming....31

Building....32

Installing Maven....34

Building the Project....35

Testing....40

A Simple Application with Spring....44

Next Steps....49

Chapter 3: Configuration and Declaration of Beans....50

The Container....50

The Sample Application....51

The Code for the Band Gateway....53

The Build....54

The Model....55

The Normalizer Interface....59

The Music Service....59

Configuration Through Annotation....65

Declaring a Spring Bean with @Component....66

Wiring Components Together with @Autowired....71

Choosing Components with @Qualifier and Bean Names....78

Constructor Injection with Annotations....85

Configuration Through XML....93

Declaring a Bean with ....93

Wiring Components Together with ....95

Wiring Components Together with ....98

Configuration Through Java Config....100

Declaring Components with @Bean....101

Using a Programmatic Configuration for ApplicationContext....102

Wiring Components Together with @Autowired with Static Configuration....103

Using @Qualifier to Select Specific Components for Wiring....104

Constructor Injection with Static Configuration....105

Testing Every Configuration with a DataProvider....107

Next Steps....111

Chapter 4: Lifecycle....112

Introduction of Lifecycle....112

Scope....113

Calling Constructors....118

Calling Methods After Construction and Before Destruction....120

Lifecycle Listeners....124

Lifecycle with JSR-250 Annotations....126

Annotated Beans with Scopes....126

Constructors with Annotated Classes....128

Calling Methods After Construction and Before Destruction....129

Lifecycle with Java Configuration....132

Additional Scopes....135

Next Steps....135

Chapter 5: Spring and Jakarta EE....136

Introduction to Jakarta EE....136

The Servlet API....138

Modern Web Application Design Principles....140

Module Structure....141

The Common Module....141

The Annotation-Based Web Application....146

Our First Standalone Working Servlet....149

Adding a Spring Context for Our Servlets....153

The XML-Based Spring Context Application....157

Next Steps....161

Chapter 6: Spring Web....162

Introduction to Spring MVC....162

MVC....162

Hello, World with MVC....163

REST Concepts....169

Using HTTP Methods Appropriately....170

Developing Our First Endpoint with MVC....173

Configuration....179

Templates and Models....185

Error Handling....188

Next Steps....192

Chapter 7: Spring Boot....193

What Is Spring Boot?....193

Setting Up a Project....195

Checking the Foundation....197

Building the Application....197

Building Our Transport Object....198

Actually Saying “Hello”....199

Testing with Spring Boot....200

Configuration in Spring Boot....203

Static Content with Spring Boot....204

Summary of the “Hello, World” Boot Mechanism....207

Spring Boot and Database Connections....207

Initializing Data with Spring Boot....209

Building an ArtistService....212

Handling Exceptions in Spring Boot....217

The Actual Implementation of ArtistService and Its Little Controller, Too....218

Testing Our ArtistController: Does It Work?....225

Next Steps....230

Chapter 8: Spring Data Access with JdbcTemplate....231

Introduction....231

Project Setup....232

Our Entity and Data Models....234

Accessing Data....244

JdbcTemplate.query()....247

@Transactional....249

The Actual MusicRepository....253

Testing MusicRepository....260

Adding the REST Endpoints....264

The ArtistController....264

The SongController....275

Next Steps....280

Chapter 9: Persistence with Spring and Spring Data....282

Introduction....282

General Architecture....283

An Important Note About Requirements....285

Creating Our Project Structure....285

The Common Code....287

The chapter09-test Project....302

The chapter09-jpa Project....313

The chapter09-mongo Project....327

Getting MongoDB....327

The Code for the chapter09-mongo Project....328

Tying Up Loose Ends....339

Next Steps....339

Chapter 10: Spring Security....340

Introduction....340

Quickstart....342

Testing....349

Customizing Your Security....351

Securing a REST Application....362

Integrating OAuth....372

The Road to Spring Security 7....379

Next Steps....380

Chapter 11: Spring Batch and Modulith....381

Introduction to Batch....381

Configuration....381

Our First Job....383

Processing and Listening....394

Introduction to Modulith....397

Verification....409

Documentation....410

Next Steps....412

Chapter 12: Next Steps....413

A Criticism of Books....413

Spring Initializr....415

Alternative JVM Languages....418

Spring WebMVC.fn....419

Spring Reactive....421

Message Queues and Spring....422

GraphQL....424

Cloud Deployment....426

Performance Metrics....427

Other Developers....429

What’s Next?....429

Index....431

This book will teach you how to use the Spring Framework to build Java-based applications, web applications, and microservices. Aimed at beginners, it has been revised and expanded to reflect the latest features and best practices for Spring 6.

After completing this book, you’ll be prepared to develop your own scalable, modular Spring-based applications.

What You Will Learn

  • Discover the most common use cases encountered in the real world
  • Learn the proper way of testing with the Spring framework
  • Create reliable, modular software
  • Build skills that will translate well across all languages and environments
  • Integrate and use data access and persistence frameworks such as Hibernate, JPA, and MongoDB
  • Get started with the most common, most-used Spring features

Who This Book Is For

Those who are new to Spring or for those who have experience with Spring but want to learn what's new in Spring 6. This book assumes you have some prior coding experience inJava, but many core concepts in Java are discussed as they’re encountered.


Похожее:

Список отзывов:

Нет отзывов к книге.