100% found this document useful (7 votes)
124 views

Instant Download Beginning Spring Boot 3: Build Dynamic Cloud-Native Java Applications and Microservices - Second Edition K. Siva Prasad Reddy PDF All Chapters

The document promotes the ebook 'Beginning Spring Boot 3: Build Dynamic Cloud-Native Java Applications and Microservices - Second Edition' by K. Siva Prasad Reddy, available for download on ebookmeta.com. It includes links to additional recommended digital products and provides an overview of the book's content, which covers various aspects of Spring Boot and its applications in developing cloud-native Java applications. The document also contains information about the authors, copyright, and the structure of the book.

Uploaded by

gombaromeyaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (7 votes)
124 views

Instant Download Beginning Spring Boot 3: Build Dynamic Cloud-Native Java Applications and Microservices - Second Edition K. Siva Prasad Reddy PDF All Chapters

The document promotes the ebook 'Beginning Spring Boot 3: Build Dynamic Cloud-Native Java Applications and Microservices - Second Edition' by K. Siva Prasad Reddy, available for download on ebookmeta.com. It includes links to additional recommended digital products and provides an overview of the book's content, which covers various aspects of Spring Boot and its applications in developing cloud-native Java applications. The document also contains information about the authors, copyright, and the structure of the book.

Uploaded by

gombaromeyaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Get the full ebook with Bonus Features for a Better Reading Experience on ebookmeta.

com

Beginning Spring Boot 3: Build Dynamic Cloud-


Native Java Applications and Microservices -
Second Edition K. Siva Prasad Reddy

https://ebookmeta.com/product/beginning-spring-boot-3-build-
dynamic-cloud-native-java-applications-and-microservices-
second-edition-k-siva-prasad-reddy/

OR CLICK HERE

DOWLOAD NOW

Download more ebook instantly today at https://ebookmeta.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Beginning Spring Boot 3 2nd Edition Siva Prasad Reddy


Katamreddy [K. Siva Prasad Reddy]

https://ebookmeta.com/product/beginning-spring-boot-3-2nd-edition-
siva-prasad-reddy-katamreddy-k-siva-prasad-reddy/

ebookmeta.com

Spring REST: Building Java Microservices and Cloud


Applications Balaji Varanasi

https://ebookmeta.com/product/spring-rest-building-java-microservices-
and-cloud-applications-balaji-varanasi/

ebookmeta.com

Beginning Helidon: Building Cloud-Native Microservices and


Applications 1st Edition Dmitry Kornilov

https://ebookmeta.com/product/beginning-helidon-building-cloud-native-
microservices-and-applications-1st-edition-dmitry-kornilov-2/

ebookmeta.com

Australian International Pictures 1946 75 1st Edition


Adrian Danks

https://ebookmeta.com/product/australian-international-
pictures-1946-75-1st-edition-adrian-danks/

ebookmeta.com
The Calling of the Grave 1st Edition Simon Beckett

https://ebookmeta.com/product/the-calling-of-the-grave-1st-edition-
simon-beckett/

ebookmeta.com

The Routledge Atlas of the First World War, 4th Edition


Martin Gilbert

https://ebookmeta.com/product/the-routledge-atlas-of-the-first-world-
war-4th-edition-martin-gilbert/

ebookmeta.com

Demon Slayer Kimetsu No Yaiba Volumes 9 10 Chapters 071


085 Koyoharu Got■ge

https://ebookmeta.com/product/demon-slayer-kimetsu-no-yaiba-
volumes-9-10-chapters-071-085-koyoharu-gotoge/

ebookmeta.com

Handbook of Economic Stagnation 1st Edition L. Randall


Wray (Editor)

https://ebookmeta.com/product/handbook-of-economic-stagnation-1st-
edition-l-randall-wray-editor/

ebookmeta.com

Kill Monsters Get Rich 2 1st Edition Logan Jacobs

https://ebookmeta.com/product/kill-monsters-get-rich-2-1st-edition-
logan-jacobs/

ebookmeta.com
Amsterdam 13th Edition Catherine Le Nevez Kate Morgan
Barbara Woolsey

https://ebookmeta.com/product/amsterdam-13th-edition-catherine-le-
nevez-kate-morgan-barbara-woolsey/

ebookmeta.com
Beginning
Spring Boot 3
Build Dynamic Cloud-Native Java
Applications and Microservices

Second Edition

K. Siva Prasad Reddy
Sai Upadhyayula
Beginning Spring Boot 3
Build Dynamic Cloud-Native Java
Applications and Microservices
Second Edition

K. Siva Prasad Reddy


Sai Upadhyayula
Beginning Spring Boot 3: Build Dynamic Cloud-Native Java Applications and
Microservices
K. Siva Prasad Reddy Sai Upadhyayula
Hyderabad, India Rotterdam, The Netherlands

ISBN-13 (pbk): 978-1-4842-8791-0 ISBN-13 (electronic): 978-1-4842-8792-7


https://doi.org/10.1007/978-1-4842-8792-7

Copyright © 2023 by K. Siva Prasad Reddy, Sai Upadhyayula


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: Laura Berendson
Coordinating Editor: Gryffin Winkler
Copy Editor: Mary Behr
Cover designed by eStudio Calamar
Cover image designed by Freepik (www.freepik.com)
Distributed to the book trade worldwide by Apress Media, LLC, 1 New York Plaza, New York, NY 10004,
U.S.A. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.
springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science +
Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail booktranslations@springernature.com; for reprint,
paperback, or audio rights, please e-mail bookpermissions@springernature.com.
Apress 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 Sales
web page at www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub (github.com/apress). For more detailed information, please visit www.apress.com/
source-­code.
Printed on acid-free paper
Table of Contents
About the Authors�������������������������������������������������������������������������������������������������� xiii

About the Technical Reviewer���������������������������������������������������������������������������������xv


Acknowledgments�������������������������������������������������������������������������������������������������xvii

Introduction������������������������������������������������������������������������������������������������������������xix

Chapter 1: Introduction to Spring Boot��������������������������������������������������������������������� 1


Overview of the Spring Framework���������������������������������������������������������������������������������������������� 1
Spring Configuration Styles���������������������������������������������������������������������������������������������������������� 2
Developing a Web Application Using SpringMVC and JPA������������������������������������������������������������ 5
A Quick Taste of Spring Boot������������������������������������������������������������������������������������������������������� 21
Easy Dependency Management�������������������������������������������������������������������������������������������� 26
Autoconfiguration������������������������������������������������������������������������������������������������������������������ 27
Embedded Servlet Container Support����������������������������������������������������������������������������������� 27
Summary������������������������������������������������������������������������������������������������������������������������������������ 28

Chapter 2: Getting Started with Spring Boot���������������������������������������������������������� 29


What Is Spring Boot?������������������������������������������������������������������������������������������������������������������ 29
Spring Boot Starters�������������������������������������������������������������������������������������������������������������� 29
Spring Boot Autoconfiguration����������������������������������������������������������������������������������������������� 30
Elegant Configuration Management�������������������������������������������������������������������������������������� 31
Spring Boot Actuator������������������������������������������������������������������������������������������������������������� 31
Easy-to-Use Embedded Servlet Container Support��������������������������������������������������������������� 31
Your First Spring Boot Application���������������������������������������������������������������������������������������������� 31
Using Spring Initializr������������������������������������������������������������������������������������������������������������ 32
Using the Spring Tool Suite���������������������������������������������������������������������������������������������������� 32
Using IntelliJ IDEA����������������������������������������������������������������������������������������������������������������� 34

iii
Table of Contents

Using NetBeans IDE��������������������������������������������������������������������������������������������������������������� 35


Exploring the Project������������������������������������������������������������������������������������������������������������� 35
The Application Entry Point Class����������������������������������������������������������������������������������������������� 41
Fat JAR Using the Spring Boot Maven Plugin����������������������������������������������������������������������������� 43
Spring Boot Using Gradle������������������������������������������������������������������������������������������������������������ 44
Maven or Gradle?������������������������������������������������������������������������������������������������������������������ 45
Summary������������������������������������������������������������������������������������������������������������������������������������ 45

Chapter 3: Spring Boot Essentials�������������������������������������������������������������������������� 47


Logging��������������������������������������������������������������������������������������������������������������������������������������� 47
Externalizing Configuration Properties��������������������������������������������������������������������������������������� 49
Type-Safe Configuration Properties��������������������������������������������������������������������������������������� 50
Relaxed Binding��������������������������������������������������������������������������������������������������������������������� 51
Validating Properties with the Bean Validation API���������������������������������������������������������������� 52
Developer Tools��������������������������������������������������������������������������������������������������������������������������� 52
Summary������������������������������������������������������������������������������������������������������������������������������������ 55

Chapter 4: Web Applications with Spring Boot������������������������������������������������������� 57


Introducing Spring MVC�������������������������������������������������������������������������������������������������������������� 58
Developing Web Application Using Spring Boot�������������������������������������������������������������������������� 59
Creating the Domain Model of a Spring Blog Application������������������������������������������������������ 60
Creating a Controller Class���������������������������������������������������������������������������������������������������� 63
Creating Views����������������������������������������������������������������������������������������������������������������������� 64
Working with Thymeleaf Forms��������������������������������������������������������������������������������������������� 66
Implementing Form Validation����������������������������������������������������������������������������������������������� 74
Using the Tomcat, Jetty, and Undertow Embedded Servlet Containers�������������������������������������� 82
Customizing Embedded Servlet Containers�������������������������������������������������������������������������������� 85
Customizing SpringMVC Configuration��������������������������������������������������������������������������������������� 88
Spring Boot Web Application as a Deployable WAR�������������������������������������������������������������������� 89
File Uploading����������������������������������������������������������������������������������������������������������������������������� 91
Using ResourceBundles for Internationalization������������������������������������������������������������������������� 92

iv
Table of Contents

ResourceBundles for Hibernate Validation Errors����������������������������������������������������������������������� 95


Error Handling����������������������������������������������������������������������������������������������������������������������������� 97
Summary���������������������������������������������������������������������������������������������������������������������������������� 100

Chapter 5: Working with JDBC����������������������������������������������������������������������������� 101


Introduction to JdbcTemplate��������������������������������������������������������������������������������������������������� 101
Using JdbcTemplate Without Spring Boot��������������������������������������������������������������������������������� 103
Using JdbcTemplate with Spring Boot�������������������������������������������������������������������������������������� 111
Initializing the Database������������������������������������������������������������������������������������������������������ 111
Testing JDBC Code�������������������������������������������������������������������������������������������������������������� 112
Using Other Connection Pooling Libraries��������������������������������������������������������������������������� 114
Using Spring Data JDBC������������������������������������������������������������������������������������������������������������ 115
Database Migration with Flyway����������������������������������������������������������������������������������������������� 116
Summary���������������������������������������������������������������������������������������������������������������������������������� 118

Chapter 6: Working with MyBatis������������������������������������������������������������������������� 119


Using the Spring Boot MyBatis Starter������������������������������������������������������������������������������������� 119
Summary���������������������������������������������������������������������������������������������������������������������������������� 124

Chapter 7: Working with JOOQ����������������������������������������������������������������������������� 125


Introduction to JOOQ����������������������������������������������������������������������������������������������������������������� 125
Using Spring Boot’s JOOQ Starter��������������������������������������������������������������������������������������������� 126
Configuring Spring Boot JOOQ Starter��������������������������������������������������������������������������������� 126
Database Schema���������������������������������������������������������������������������������������������������������������� 127
Code Generation Using the JOOQ Maven Codegen Plugin��������������������������������������������������� 128
Using JOOQ DSL������������������������������������������������������������������������������������������������������������������ 133
Summary���������������������������������������������������������������������������������������������������������������������������������� 138

Chapter 8: Working with JPA�������������������������������������������������������������������������������� 139


Introducing the Spring Data JPA����������������������������������������������������������������������������������������������� 139
Using Spring Data JPA with Spring Boot����������������������������������������������������������������������������������� 142
Using the Sort and Pagination Features������������������������������������������������������������������������������ 146
Summary���������������������������������������������������������������������������������������������������������������������������������� 148

v
Table of Contents

Chapter 9: Working with MongoDB���������������������������������������������������������������������� 149


Introducing MongoDB��������������������������������������������������������������������������������������������������������������� 149
Installing MongoDB������������������������������������������������������������������������������������������������������������������� 150
Installing MongoDB on Windows����������������������������������������������������������������������������������������� 150
Installing MongoDB on macOS�������������������������������������������������������������������������������������������� 152
Installing MongoDB on Linux����������������������������������������������������������������������������������������������� 152
Getting Started with MongoDB Using the Mongo Shell������������������������������������������������������������� 152
Introducing Spring Data MongoDB�������������������������������������������������������������������������������������������� 153
Using Embedded Mongo for Testing����������������������������������������������������������������������������������������� 158
Summary���������������������������������������������������������������������������������������������������������������������������������� 160

Chapter 10: Building REST APIs Using Spring Boot���������������������������������������������� 161


Introduction to RESTful Web Services��������������������������������������������������������������������������������������� 161
REST API Using SpringMVC������������������������������������������������������������������������������������������������������� 163
Using Data Transfer Objects������������������������������������������������������������������������������������������������ 165
Continue Building the REST API������������������������������������������������������������������������������������������� 170
Defining an HTTP Response for the API������������������������������������������������������������������������������� 172
CORS (Cross-Origin Resource Sharing) Support������������������������������������������������������������������ 173
REST API Using Spring Data REST��������������������������������������������������������������������������������������������� 176
Sorting and Pagination�������������������������������������������������������������������������������������������������������� 179
CORS Support in Spring Data REST������������������������������������������������������������������������������������� 180
Exception Handling������������������������������������������������������������������������������������������������������������������� 181
Exercise������������������������������������������������������������������������������������������������������������������������������������ 184
Summary���������������������������������������������������������������������������������������������������������������������������������� 184

Chapter 11: Reactive Programming Using Spring WebFlux���������������������������������� 185


Introduction to Reactive Programming������������������������������������������������������������������������������������� 186
Reactive Streams���������������������������������������������������������������������������������������������������������������� 186
Project Reactor�������������������������������������������������������������������������������������������������������������������� 187
Reactive Web Applications Using Spring WebFlux�������������������������������������������������������������������� 189
WebFlux Using the Annotation-Based Programming Model������������������������������������������������ 190
WebFlux Using a Functional Programming Model��������������������������������������������������������������� 196

vi
Table of Contents

Working with Spring Data R2DBC���������������������������������������������������������������������������������������� 205


Reactive WebClient�������������������������������������������������������������������������������������������������������������� 209
Testing Spring WebFlux Applications����������������������������������������������������������������������������������� 210
Summary���������������������������������������������������������������������������������������������������������������������������������� 213

Chapter 12: Securing Web Applications��������������������������������������������������������������� 215


Spring Security in Spring Boot Web Application����������������������������������������������������������������������� 215
Implementing In-Memory Authentication���������������������������������������������������������������������������� 218
Implementing Custom User Authentication������������������������������������������������������������������������� 218
Custom Spring Security Configuration�������������������������������������������������������������������������������� 221
Implementing Logout Functionality������������������������������������������������������������������������������������� 224
Implementing User Registration������������������������������������������������������������������������������������������ 226
Hashing Passwords Using PasswordEncoder��������������������������������������������������������������������� 230
Implementing the Remember-Me Feature�������������������������������������������������������������������������� 231
Simple Hash-Based Token as a Cookie������������������������������������������������������������������������������� 232
Persistent Tokens���������������������������������������������������������������������������������������������������������������� 234
Cross-Site Request Forgery Protection������������������������������������������������������������������������������������� 236
Method-Level Security�������������������������������������������������������������������������������������������������������������� 237
Securing Spring Boot REST APIs using OAuth2������������������������������������������������������������������������� 240
What Is OAuth2.0?��������������������������������������������������������������������������������������������������������������� 240
OAuth Grant Types��������������������������������������������������������������������������������������������������������������� 242
Introduction to OIDC������������������������������������������������������������������������������������������������������������ 245
Introduction to Spring Authorization Server������������������������������������������������������������������������ 246
Setting Up Spring Authorization Server������������������������������������������������������������������������������� 246
Testing the Authorization Server Using Client Credentials�������������������������������������������������� 256
Configuring the Resource Server���������������������������������������������������������������������������������������� 260
Testing the Authorization Server Using the Authorization Code Flow���������������������������������� 262
Summary���������������������������������������������������������������������������������������������������������������������������������� 266

vii
Table of Contents

Chapter 13: Spring Boot Actuator������������������������������������������������������������������������� 267


Introducing the Spring Boot Actuator���������������������������������������������������������������������������������������� 267
Exploring Actuator’s Endpoints������������������������������������������������������������������������������������������������� 269
The /info Endpoint��������������������������������������������������������������������������������������������������������������� 270
The /health Endpoint����������������������������������������������������������������������������������������������������������� 271
The /beans Endpoint������������������������������������������������������������������������������������������������������������ 272
The /conditions Endpoint����������������������������������������������������������������������������������������������������� 273
The /mappings Endpoint������������������������������������������������������������������������������������������������������ 275
The /configprops Endpoint�������������������������������������������������������������������������������������������������� 276
The /metrics Endpoint��������������������������������������������������������������������������������������������������������� 277
The /env Endpoint���������������������������������������������������������������������������������������������������������������� 278
The /httptrace Endpoint������������������������������������������������������������������������������������������������������� 279
The /threaddump Endpoint�������������������������������������������������������������������������������������������������� 280
The /loggers Endpoint��������������������������������������������������������������������������������������������������������� 281
The /logfile Endpoint����������������������������������������������������������������������������������������������������������� 283
The /shutdown Endpoint������������������������������������������������������������������������������������������������������ 284
Customizing Actuator Endpoints����������������������������������������������������������������������������������������������� 285
Securing Actuator Endpoints����������������������������������������������������������������������������������������������������� 286
Implementing Custom Health Indicators����������������������������������������������������������������������������������� 286
Capturing Custom Application Metrics�������������������������������������������������������������������������������������� 289
CORS Support for Actuator Endpoints��������������������������������������������������������������������������������������� 292
Monitoring and Management Over JMX������������������������������������������������������������������������������������ 292
Summary���������������������������������������������������������������������������������������������������������������������������������� 293

Chapter 14: Testing Spring Boot Applications������������������������������������������������������ 295


Testing Spring Boot Applications���������������������������������������������������������������������������������������������� 296
Testing with Mock Implementations����������������������������������������������������������������������������������������� 301
Testing with Mockito����������������������������������������������������������������������������������������������������������� 303
Testing Slices of Application Using @*Test Annotations����������������������������������������������������������� 308
Testing SpringMVC Controllers Using @WebMvcTest���������������������������������������������������������� 308
Testing SpringMVC REST Controllers Using @WebMvcTest������������������������������������������������ 310

viii
Table of Contents

Testing Persistence Layer Components Using @DataJpaTest and @JdbcTest������������������� 312


Testing Persistence Layer Using TestContainers����������������������������������������������������������������� 317
Summary���������������������������������������������������������������������������������������������������������������������������������� 323

Chapter 15: GraphQL with Spring Boot����������������������������������������������������������������� 325


Introduction to GraphQL������������������������������������������������������������������������������������������������������������ 325
Working with GraphQL and Spring Boot������������������������������������������������������������������������������������ 328
Creating a GraphQL Controller��������������������������������������������������������������������������������������������� 330
Enabling GraphiQL UI Client������������������������������������������������������������������������������������������������� 332
Testing Support in Spring for GraphQL�������������������������������������������������������������������������������������� 333
Summary���������������������������������������������������������������������������������������������������������������������������������� 339

Chapter 16: Deploying Spring Boot Applications�������������������������������������������������� 341


Running Spring Boot Applications in Production Mode������������������������������������������������������������� 342
Deploying Spring Boot Application on Heroku�������������������������������������������������������������������������� 344
Running a Spring Boot Application on Docker�������������������������������������������������������������������������� 352
Installing Docker������������������������������������������������������������������������������������������������������������������ 353
Running a Spring Boot Application in a Docker Container��������������������������������������������������� 354
Creating Layered Docker Images���������������������������������������������������������������������������������������� 357
Using Cloud-Native Buildpacks������������������������������������������������������������������������������������������� 358
Running Multiple Containers Using docker-compose���������������������������������������������������������� 359
Summary���������������������������������������������������������������������������������������������������������������������������������� 360

Chapter 17: Spring Boot Autoconfiguration���������������������������������������������������������� 361


Exploring the Power of @Conditional���������������������������������������������������������������������������������������� 361
Using @Conditional Based on System Properties��������������������������������������������������������������� 362
Using @Conditional Based on the Presence or Absence of a Java Class���������������������������� 365
Using @Conditional Based on the Configured Spring Beans����������������������������������������������� 366
Using @Conditional Based on a Property’s Configuration��������������������������������������������������� 367
Spring Boot’s Built-In @Conditional Annotations���������������������������������������������������������������������� 369
How Spring Boot Autoconfiguration Works������������������������������������������������������������������������������� 372
Summary���������������������������������������������������������������������������������������������������������������������������������� 376

ix
Table of Contents

Chapter 18: Creating a Custom Spring Boot Starter��������������������������������������������� 377


Introducing Twitter4j����������������������������������������������������������������������������������������������������������������� 377
Custom Spring Boot Starter������������������������������������������������������������������������������������������������������ 378
Creating the twitter4j-spring-boot-autoconfigure Module�������������������������������������������������� 379
Twitter4j Properties to Hold the Twitter4j Config Parameters��������������������������������������������������� 381
Twitter4j Autoconfiguration to Autoconfigure Twitter4j������������������������������������������������������� 383
Creating the twitter4j-spring-boot-starter Module�������������������������������������������������������������� 385
Application Using twitter4j-spring-boot-starter������������������������������������������������������������������������ 387
Summary���������������������������������������������������������������������������������������������������������������������������������� 391

Chapter 19: Spring Boot with Kotlin, Scala, and Groovy��������������������������������������� 393
Using Spring Boot with Groovy������������������������������������������������������������������������������������������������� 393
Introducing Groovy�������������������������������������������������������������������������������������������������������������� 393
Creating a Spring Boot Application Using Groovy���������������������������������������������������������������� 397
Using Spring Boot with Scala���������������������������������������������������������������������������������������������������� 402
Introducing Scala���������������������������������������������������������������������������������������������������������������� 403
Creating a Spring Boot Application Using Scala������������������������������������������������������������������ 404
Using Spring Boot with Kotlin��������������������������������������������������������������������������������������������������� 410
Introducing Kotlin���������������������������������������������������������������������������������������������������������������� 410
Creating a Spring Boot Application Using Kotlin������������������������������������������������������������������ 411
Summary���������������������������������������������������������������������������������������������������������������������������������� 417

Chapter 20: Introducing JHipster������������������������������������������������������������������������� 419


Introducing JHipster������������������������������������������������������������������������������������������������������������������ 419
Installing JHipster��������������������������������������������������������������������������������������������������������������������� 420
Prerequisites����������������������������������������������������������������������������������������������������������������������� 420
Creating a JHipster Application������������������������������������������������������������������������������������������������� 420
Creating Entities������������������������������������������������������������������������������������������������������������������������ 424
Using the JHipster Entity Sub-Generator����������������������������������������������������������������������������� 425
Using JDL Studio����������������������������������������������������������������������������������������������������������������� 426
Managing Relationships������������������������������������������������������������������������������������������������������������ 426
Summary���������������������������������������������������������������������������������������������������������������������������������� 429

x
Table of Contents

Chapter 21: Spring Native������������������������������������������������������������������������������������ 431


Getting Started�������������������������������������������������������������������������������������������������������������������������� 432
Building a Native Image Using Buildpacks������������������������������������������������������������������������������� 432
Building Native Images Using GraalVM Native Build Tools�������������������������������������������������������� 435
Limitations of Spring Native������������������������������������������������������������������������������������������������������ 438
Summary���������������������������������������������������������������������������������������������������������������������������������� 438

Index��������������������������������������������������������������������������������������������������������������������� 439

xi
About the Authors
Siva Prasad Reddy Katamareddy is a software architect with 16 years of experience
in building scalable distributed enterprise applications. He has worked in banking
and e-commerce domains using Java, Kotlin, GoLang, Spring Boot, JPA/Hibernate,
microservices, REST APIs, SQL, and NoSQL databases. His current technical focus
is on modern architectures, including microservices, CI/CD, and DevOps, as well as
infrastructure automation using Jenkins, Terraform, AWS CDK, and Pulumi.

Sai Subramanyam Upadhyayula is a passionate software engineer who likes to share


his knowledge about Java and Spring Boot through his blog and YouTube Channel,
"Programming Techie." He has experience working with a variety of technologies
including Java, Kotlin, Typescript, Spring Boot, JPA/Hibernate, MongoDB, Angular,
and Golang. He also dabbles with DevOps-related activities by working with Jenkins
and AWS.

xiii
About the Technical Reviewer
Preethi Vasudev earned an MS in Computer Information Systems and Cyber Security
from Auburn University, Alabama. She is an Oracle-certified Java 8 programmer with
more than 15 years of industry experience in investment banking, healthcare, and other
areas. She is interested in Java and related technologies and enjoys participating in
coding competitions.

xv
Acknowledgments
I would like to thank my wife, Neha Jain, and my family members for their continuous
support all the days I spent writing this book.
I would like to express my gratitude to the Apress team, specifically to Steve Anglin
and Mark Powers, for their continuous support throughout the journey. I would also like
to thank the reviewers for providing valuable feedback that helped improve the quality of
the content.

Siva Prasad Reddy Katamareddy

I would like to thank and dedicate this to my lovely wife, Sowmya, for her continuous
support and my father, Phani Kumar, my mother, Malliswari, and my sister, Anusha.
I would like to also thank Mark Powers and Shonmirin for their continuous support
and patience throughout the journey. Special thanks also to the reviewers for the
valuable feedback.

Sai Subramanyam Upadhyayula

xvii
Other documents randomly have
different content
If the second copy is also defective, you may demand a refund
in writing without further opportunities to fix the problem.

1.F.4. Except for the limited right of replacement or refund set


forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’,
WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of
damages. If any disclaimer or limitation set forth in this
agreement violates the law of the state applicable to this
agreement, the agreement shall be interpreted to make the
maximum disclaimer or limitation permitted by the applicable
state law. The invalidity or unenforceability of any provision of
this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the


Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and
distribution of Project Gutenberg™ electronic works, harmless
from all liability, costs and expenses, including legal fees, that
arise directly or indirectly from any of the following which you
do or cause to occur: (a) distribution of this or any Project
Gutenberg™ work, (b) alteration, modification, or additions or
deletions to any Project Gutenberg™ work, and (c) any Defect
you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new
computers. It exists because of the efforts of hundreds of
volunteers and donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project
Gutenberg™’s goals and ensuring that the Project Gutenberg™
collection will remain freely available for generations to come. In
2001, the Project Gutenberg Literary Archive Foundation was
created to provide a secure and permanent future for Project
Gutenberg™ and future generations. To learn more about the
Project Gutenberg Literary Archive Foundation and how your
efforts and donations can help, see Sections 3 and 4 and the
Foundation information page at www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-
profit 501(c)(3) educational corporation organized under the
laws of the state of Mississippi and granted tax exempt status
by the Internal Revenue Service. The Foundation’s EIN or
federal tax identification number is 64-6221541. Contributions
to the Project Gutenberg Literary Archive Foundation are tax
deductible to the full extent permitted by U.S. federal laws and
your state’s laws.

The Foundation’s business office is located at 809 North 1500


West, Salt Lake City, UT 84116, (801) 596-1887. Email contact
links and up to date contact information can be found at the
Foundation’s website and official page at
www.gutenberg.org/contact
Section 4. Information about Donations to
the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission
of increasing the number of public domain and licensed works
that can be freely distributed in machine-readable form
accessible by the widest array of equipment including outdated
equipment. Many small donations ($1 to $5,000) are particularly
important to maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws


regulating charities and charitable donations in all 50 states of
the United States. Compliance requirements are not uniform
and it takes a considerable effort, much paperwork and many
fees to meet and keep up with these requirements. We do not
solicit donations in locations where we have not received written
confirmation of compliance. To SEND DONATIONS or determine
the status of compliance for any particular state visit
www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states


where we have not met the solicitation requirements, we know
of no prohibition against accepting unsolicited donations from
donors in such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot


make any statements concerning tax treatment of donations
received from outside the United States. U.S. laws alone swamp
our small staff.

Please check the Project Gutenberg web pages for current


donation methods and addresses. Donations are accepted in a
number of other ways including checks, online payments and
credit card donations. To donate, please visit:
www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could
be freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose
network of volunteer support.

Project Gutenberg™ eBooks are often created from several


printed editions, all of which are confirmed as not protected by
copyright in the U.S. unless a copyright notice is included. Thus,
we do not necessarily keep eBooks in compliance with any
particular paper edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg
Literary Archive Foundation, how to help produce our new
eBooks, and how to subscribe to our email newsletter to hear
about new eBooks.

You might also like