Share E-Book

Hands-on Application Development using Spring Boot (Shagun Bakliwal) (z-library.sk, 1lib.sk, z-lib.sk)

Author

Rating 3.5 AI initial rating

Log in to rate

Framework
Language English

A pragmatic guide for Java developers to help build Microservices and Cloud Apps using Spring Boot. KEY FEATURES ● Develops microservices from start to finish using the Spring Boot Framework. ● Creates cloud-native applications using Spring Boot's production-ready features. ● Covers the API gateway, unit testing, cloud deployments, and managing high-traffic applications. DESCRIPTION Spring is an excellent framework for developing both web and cloud-native applications. This book on application development using Spring Boot simplifies the process of writing boilerplate code for complex software. It allows developers to concentrate on the application's concept rather than on the internal Java configuration. This book will guide you on how to make the best use of the strength that Spring Boot provides. You'll gain an understanding of how Spring Boot configuration works in conjunction with application development, including auto-configuration and overriding default configurations. You will learn to develop scalable, dependable microservices to accelerate the development lifecycle of a cloud-based application. Each chapter will walk you through the features of Spring Boot as a Software Development Framework, such as performing Create, Read, Update, and Delete (CRUD) operations on a database and securing web services with appropriate logging. By the end of this book, you will develop, test, and deploy applications ready for production and how to establish them as cloud-based applications. The readers will also gain the expertise of writing unit and integration test cases. WHAT YOU WILL LEARN ● Get to know Spring Boot and all its capabilities. ● Build start-to-end production-ready applications. ● Explore the API Gateway and practice how to run request routing. ● Learn API doc tools like Swagger and host your apps on Cloud. ● Practice how to balance the application's load when the system is under high traffic. ● Learn to write unit tests and integration tests for bug-free c

Format PDF
Size 8.7 MB
(First 20 pages)

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Page 1
(This page has no text content)
Page 2
Hands-on Application Development using Spring Boot Building Modern Cloud Native Applications by Learning RESTFul API, Microservices, CRUD Operations, Unit Testing, and Deployment Shagun Bakliwal www.bpbonline.com
Page 3
FIRST EDITION 2022 Copyright © BPB Publications, India ISBN: 978-93-91030-22-3 All Rights Reserved. No part of this publication may be reproduced, distributed or transmitted in any form or by any means or stored in a database or retrieval system, without the prior written permission of the publisher with the exception to the program listings which may be entered, stored and executed in a computer system, but they can not be reproduced by the means of publication, photocopy, recording, or by any electronic and mechanical means. LIMITS OF LIABILITY AND DISCLAIMER OF WARRANTY The information contained in this book is true to correct and the best of author’s and publisher’s knowledge. The author has made every effort to ensure the accuracy of these publications, but publisher cannot be held responsible for any loss or damage arising from any information in this book. All trademarks referred to in the book are acknowledged as properties of their respective owners but BPB Publications cannot guarantee the accuracy of this information.
Page 4
www.bpbonline.com
Page 5
Dedicated to All Tech-Learners and My Mom, who I always care for.
Page 6
About the Author Shagun Bakliwal has six years of work experience developing applications in languages such a Java, Spring Boot, Servlets, JSP, and HTML. He focuses primarily on the client-side and cloud technologies. He has worked with multiple MNCs based in India and currently lives in the city of dreams - Mumbai. If he isn’t around his friends and family, then you can find him around his laptop or mobile. As he is very tech-savvy, he has cracked most interviews with the help of deep knowledge in Java and Spring Boot. Prior to writing this book, he was also a technical reviewer for one of the publishers for Cloud Native Application. He is certified in many courses like MongoDB Basics, Google Analytics for Beginners, EMC Academic Associate, Cloud Infrastructure and Services and Predix developer. Over the years, he has implemented ideas ranging from basics to more complex paradigms and has acquired bounty of knowledge around many software tools that he loves to share.
Page 7
About the Reviewer Deepak Dhaka has six years of work experience in Java application development, API development. He has experience creating infra in Microservices architecture, handling security, and overall architecture development using tools like IntelliJ, Eclipse, and STS with programming languages such as Java, JavaScript, and so on, with a framework in Spring Boot. Deepak pursued B. Tech in Computer Science and Engineering from Amity University of Engineering, Amity University, Jaipur. He has worked with companies such as Wipro Technologies, the National Bank of Jamaica, Instant Systems, and HCL. He is currently working as a Senior Software Engineer in SOPHOS, a leading Security Product Company, Bangalore.
Page 8
Acknowledgements There are a few people who I want to thank personally for their continued support in my life before and after writing this book. First and foremost, I would like to thank my parents for sending me to an Engineering Institute where I fulfilled my passion for coding. This book wouldn’t have happened if I hadn’t had the curiosity and the power about coding which aroused when I met Prof. Praful Kelkar. He always taught to aim higher and stand different in crowd based on the skills few can have. Along the way, we got feedback from several peer reviewers who made sure that the book stayed on target and covered the accurate and latest stuff. Many thanks in particular to Priyanka Deshpande, my Content Development Editor. Thanks to the technical proofer Deepak Dhaka who was thorough, clear and helpful in reviewing the book. Also, much thanks to Shubham Shrivastava and Rajat Sethi for standing with me in happy and sad times throughout the book writing. Finally, I would like to thank Priyanka Deshpande and Surbhi Saxena at BPB Publications for giving me this opportunity to write my first book for them and staying in contact throughout the book writing.
Page 9
Preface Spring is an excellent framework for developing both web and cloud-native applications. This book on application development using Spring Boot simplifies the process of writing boilerplate code for complex software. It allows developers to concentrate on the application’s concept rather than on the internal Java configuration. This book will guide you on how to make the best use of the strength that Spring Boot provides. You’ll gain an understanding of how Spring Boot configuration works in conjunction with application development, including auto-configuration and overriding default configurations. You will learn to develop scalable, dependable microservices to accelerate the development lifecycle of a cloud-based application. Each chapter will walk you through the features of Spring Boot as a Software Development Framework, such as performing Create, Read, Update, and Delete (CRUD) operations on a database and securing web services with appropriate logging. By the end of this book, you will develop, test, and deploy applications ready for production and how to establish them as cloud-based applications. The readers will also gain the expertise of writing unit and integration test cases. Over the 12 chapters in this book, you will learn the following: Chapter 1 introduces the Spring Boot Framework with the latest version 2.4.3. It will cover the basics, features, advantages of
Page 10
Spring Boot, when to use, when not to use Spring Boot and setting up the workspace with the tools like Spring Tool Suite (STS), Spring Initializer, Maven, and Gradle as build tool. This chapter also explains the 12-Factor App features. Chapter 2 discusses on how to create a basic Spring Boot Application step by step using Maven and Gradle as build tools. It also explains the Maven and Gradle build file components. Chapter 3 describes the different Spring Boot Starter dependencies available which are used commonly for developing an application and how those dependencies can be configured by just writing the configurations and enabling them for auto-configuration. Chapter 4 is a key chapter which discusses in depth the definitions and usage of various annotations used while developing Spring Boot Application so that you will have the idea of using them before developing the application. Chapter 5 helps you deep dive into application development that interacts with database – H2 and MySQL and caches data that are frequently used. Chapter 6 helps to create different profiles that can be used to create microservices, the interaction among them using RestTemplate with Eureka Service Discovery and API Gateway. It also includes different actuator endpoints and creating own health check endpoint.
Page 11
Chapter 7 explains how to enable security in the RESTFul APIs created in Spring Boot Application. It explains concepts of Authentication and Authorization along-with Spring Filters. It also teaches how to implement OAuth 2.0 security. Chapter 8 helps to understand how to sustain high traffic with different number of same applications running on the same machine so that resiliency of application is taken care by having client-side load balancing. If there is any part of the application that is continuously failing in serving the requests, then implementing the Circuit Breaker gracefully degrades the functionality so that application continues to operate when a related service fails, preventing the failure from cascading and giving the failing service time to recover. Chapter 9 describes different ways of using logback configuration file for logging events. It also includes the Zipkin for tracing logs with tools like Sleuth, ElasticSearch, Logstash, and Kibana (ELK). Chapter 10 explains how to document the APIs so that the consumers can consume it easily using Swagger. This chapter also explains how we can generate the Data Transfer Objects classes using YAML specification. Chapter 11 describes the process of writing test cases in RESTFul Microservices using JUnit and Mockito testing framework. It also shows how to check the code coverage of the test cases developed in addition to automating test cases using Cucumber framework.
Page 12
Chapter 12 describes the features and creation of docker for running the application in a containerized manner. It also includes the deployment of an application on Heroku Cloud so that its services are available on internet.
Page 13
Downloading the code bundle and coloured images: Please follow the link to download the Code Bundle and the Coloured Images of the book: https://rebrand.ly/75ee5f Errata We take immense pride in our work at BPB Publications and follow best practices to ensure the accuracy of our content to provide with an indulging reading experience to our subscribers. Our readers are our mirrors, and we use their inputs to reflect and improve upon human errors, if any, that may have occurred during the publishing processes involved. To let us maintain the quality and help us reach out to any readers who might be having difficulties due to any unforeseen errors, please write to us at : errata@bpbonline.com Your support, suggestions and feedbacks are highly appreciated by the BPB Publications’ Family.
Page 14
Did you know that BPB offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.bpbonline.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at business@bpbonline.com for more details. At you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on BPB books and eBooks.
Page 15
BPB is searching for authors like you If you're interested in becoming an author for BPB, please visit www.bpbonline.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea. The code bundle for the book is also hosted on GitHub at In case there's an update to the code, it will be updated on the existing GitHub repository. We also have other code bundles from our rich catalog of books and videos available at Check them out! PIRACY If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at business@bpbonline.com with a link to the material. If you are interested in becoming an author
Page 16
If there is a topic that you have expertise in, and you are interested in either writing or contributing to a book, please visit REVIEWS Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at BPB can understand what you think about our products, and our authors can see your feedback on their book. Thank you! For more information about BPB, please visit
Page 17
Table of Contents 1. Getting Started with Spring Boot Structure Objectives Introduction to Spring Boot Features of Spring Boot Advantages of Spring Boot Breaking the monolithic way of developing software When to start using microservices? When not to start using microservices? System requirements Setting up the environment Installing Java Development Kit 8 ( jdk-8u261-windows-x64) Installing Apache Maven (apache-maven-3.6.3) Installing Gradle (gradle 6.6) Installing Spring Tool Suite (STS 4) The 12-factor app Spring Initializr Conclusion Points to remember Questions 2. Developing Your First Spring Boot Application Structure Objectives Starting with Spring Initializr Build tools – Maven and Gradle Understanding the pom.xml
Page 18
Understanding build.gradle Building an application using Maven Building an application using Gradle Understanding the entry point class and SpringBootApplication annotation Bootstrap ApplicationContext Java configuration XML configuration Annotation configuration Conclusion Points to remember Questions 3. Spring Boot Starter Dependencies and Auto-Configuration Structure Objectives Spring Boot starters Spring Boot starter dependencies and their configuration spring-boot-starter-parent spring-boot-starter-web spring-boot-starter-data-jpa spring-boot-starter-test spring-boot-starter-security spring-boot-starter-actuator spring-boot-starter-logging spring-boot-starter-cache spring-boot-starter-aop Understanding auto-configuration Conditional on class Conditional on bean Conditional on property
Page 19
Conclusion Points to remember Questions 4. Spring Boot Annotations Structure Objectives Java annotations Existence of Spring annotations Spring and Spring Boot annotations Core Spring framework annotations @Bean @Autowired @ComponentScan @Configuration @ConfigurationProperties @TestPropertySource @Lazy @Qualifier @Primary @Value Spring framework stereotype annotations @Component @Controller @Repository @Service Spring Boot annotations @EnableAutoConfiguration @SpringBootApplication @SpringBootConfiguration
Page 20
Spring task execution annotations @Async @EnableScheduling @Scheduled Spring profiles annotations @Profile @ActiveProfiles Jakarta annotations @PreDestroy @PostConstruct Conclusion Points to remember Questions 5. Working with Spring Data JPA and Caching Structure Objective Accessing relational data using JdbcTemplate with the in-memory database Accessing relational data using Spring data JPA with the in- memory database MySQL and its installation Accessing relational data using Spring data JPA with MySQL Query methods in Spring data JPA Caching Conclusion Points to remember Questions 6. Building RESTFul Microservices
The above is a preview of the first 20 pages. Register to read the complete e-book.

Recommended for You

Loading recommended books...
Failed to load, please try again later

Tip the Site

Scan the WeChat Pay or Alipay code to tip. No login required.

WeChat Pay
Alipay
← Back to List